Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GitLab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
projects.thm.de
GitLab
Commits
83c96d73
Commit
83c96d73
authored
Oct 02, 2018
by
Daniel Gerhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "use fileuploader dynamic path method in uploads manager and add spec"
This reverts commit
07ec2c7b
.
parent
b7c46451
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
16 deletions
+8
-16
app/uploaders/file_uploader.rb
app/uploaders/file_uploader.rb
+2
-6
lib/gitlab/import_export/uploads_manager.rb
lib/gitlab/import_export/uploads_manager.rb
+6
-1
spec/uploaders/file_uploader_spec.rb
spec/uploaders/file_uploader_spec.rb
+0
-9
No files found.
app/uploaders/file_uploader.rb
View file @
83c96d73
...
...
@@ -15,7 +15,7 @@ class FileUploader < GitlabUploader
prepend
ObjectStorage
::
Extension
::
RecordsUploads
MARKDOWN_PATTERN
=
%r{
\!
?
\[
.*?
\]\(
/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)
\)
}
DYNAMIC_PATH_PATTERN
=
%r{
.*
(?<secret>
\h
{32})/(?<identifier>.*)}
DYNAMIC_PATH_PATTERN
=
%r{(?<secret>
\h
{32})/(?<identifier>.*)}
after
:remove
,
:prune_store_dir
...
...
@@ -67,10 +67,6 @@ class FileUploader < GitlabUploader
SecureRandom
.
hex
end
def
self
.
extract_dynamic_path
(
path
)
DYNAMIC_PATH_PATTERN
.
match
(
path
)
end
def
upload_paths
(
identifier
)
[
File
.
join
(
secret
,
identifier
),
...
...
@@ -137,7 +133,7 @@ class FileUploader < GitlabUploader
return
if
apply_context!
(
value
.
uploader_context
)
# fallback to the regex based extraction
if
matches
=
self
.
class
.
extract_dynamic_pat
h
(
value
.
path
)
if
matches
=
DYNAMIC_PATH_PATTERN
.
matc
h
(
value
.
path
)
@secret
=
matches
[
:secret
]
@identifier
=
matches
[
:identifier
]
end
...
...
lib/gitlab/import_export/uploads_manager.rb
View file @
83c96d73
...
...
@@ -38,7 +38,12 @@ module Gitlab
private
def
add_upload
(
upload
)
uploader_context
=
FileUploader
.
extract_dynamic_path
(
upload
).
named_captures
.
symbolize_keys
secret
,
identifier
=
upload
.
split
(
'/'
).
last
(
2
)
uploader_context
=
{
secret:
secret
,
identifier:
identifier
}
UploadService
.
new
(
@project
,
File
.
open
(
upload
,
'r'
),
FileUploader
,
uploader_context
).
execute
.
to_h
end
...
...
spec/uploaders/file_uploader_spec.rb
View file @
83c96d73
...
...
@@ -141,15 +141,6 @@ describe FileUploader do
end
end
describe
'.extract_dynamic_path'
do
it
'works with hashed storage'
do
path
=
'export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads/72a497a02fe3ee09edae2ed06d390038/dummy.txt'
expect
(
described_class
.
extract_dynamic_path
(
path
)[
:identifier
]).
to
eq
(
'dummy.txt'
)
expect
(
described_class
.
extract_dynamic_path
(
path
)[
:secret
]).
to
eq
(
'72a497a02fe3ee09edae2ed06d390038'
)
end
end
describe
'#secret'
do
it
'generates a secret if none is provided'
do
expect
(
described_class
).
to
receive
(
:generate_secret
).
and_return
(
'secret'
)
...
...
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