Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7c1bf3b2
Commit
7c1bf3b2
authored
Dec 17, 2020
by
Vladimir Shushlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not change the input parameter of the service
parent
3aec75d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
app/services/pages/zip_directory_service.rb
app/services/pages/zip_directory_service.rb
+14
-7
No files found.
app/services/pages/zip_directory_service.rb
View file @
7c1bf3b2
...
...
@@ -2,6 +2,8 @@
module
Pages
class
ZipDirectoryService
include
Gitlab
::
Utils
::
StrongMemoize
InvalidArchiveError
=
Class
.
new
(
RuntimeError
)
InvalidEntryError
=
Class
.
new
(
RuntimeError
)
...
...
@@ -14,8 +16,7 @@ module Pages
def
execute
raise
InvalidArchiveError
unless
valid_work_directory?
@input_dir
=
File
.
realpath
(
@input_dir
)
output_file
=
File
.
join
(
@input_dir
,
"@migrated.zip"
)
# '@' to avoid any name collision with groups or projects
output_file
=
File
.
join
(
real_dir
,
"@migrated.zip"
)
# '@' to avoid any name collision with groups or projects
FileUtils
.
rm_f
(
output_file
)
...
...
@@ -34,7 +35,7 @@ module Pages
private
def
write_entry
(
zipfile
,
zipfile_path
)
disk_file_path
=
File
.
join
(
@input
_dir
,
zipfile_path
)
disk_file_path
=
File
.
join
(
real
_dir
,
zipfile_path
)
unless
valid_path?
(
disk_file_path
)
# archive without public directory is completelly unusable
...
...
@@ -78,21 +79,27 @@ module Pages
def
valid_path?
(
disk_file_path
)
realpath
=
File
.
realpath
(
disk_file_path
)
realpath
==
File
.
join
(
@input
_dir
,
PUBLIC_DIR
)
||
realpath
.
start_with?
(
File
.
join
(
@input
_dir
,
PUBLIC_DIR
+
"/"
))
realpath
==
File
.
join
(
real
_dir
,
PUBLIC_DIR
)
||
realpath
.
start_with?
(
File
.
join
(
real
_dir
,
PUBLIC_DIR
+
"/"
))
# happens if target of symlink isn't there
rescue
=>
e
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
input_dir:
@input
_dir
,
disk_file_path:
disk_file_path
)
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
input_dir:
real
_dir
,
disk_file_path:
disk_file_path
)
false
end
def
valid_work_directory?
Dir
.
exist?
(
@input
_dir
)
Dir
.
exist?
(
real
_dir
)
rescue
=>
e
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
input_dir:
@input_dir
)
false
end
def
real_dir
strong_memoize
(
:real_dir
)
do
File
.
realpath
(
@input_dir
)
rescue
nil
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment