diff options
author | James Lopez <james@jameslopez.es> | 2018-07-13 16:13:13 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2018-07-13 16:13:13 +0200 |
commit | 07ec2c7bd00e6d0487e3f81864af982ec73365b2 (patch) | |
tree | 97395261df8101c2f3455786ff8dcf3fbb482295 /app/uploaders/file_uploader.rb | |
parent | 1263367c3fda134db41e115965c5134933dcb7c7 (diff) | |
download | gitlab-ce-07ec2c7bd00e6d0487e3f81864af982ec73365b2.tar.gz |
use fileuploader dynamic path method in uploads manager and add spec48745-project-exports-fail-when-uploads-have-been-migrated-to-object-storage
Diffstat (limited to 'app/uploaders/file_uploader.rb')
-rw-r--r-- | app/uploaders/file_uploader.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 21292ddcf44..83f7b99d2a5 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -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,6 +67,10 @@ 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), @@ -143,7 +147,7 @@ class FileUploader < GitlabUploader return if apply_context!(value.uploader_context) # fallback to the regex based extraction - if matches = DYNAMIC_PATH_PATTERN.match(value.path) + if matches = self.class.extract_dynamic_path(value.path) @secret = matches[:secret] @identifier = matches[:identifier] end |