diff options
author | Stan Hu <stanhu@gmail.com> | 2017-11-21 21:52:27 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2017-11-21 23:00:41 +0300 |
commit | 5fe4a302ef25894fb26782c7cb57e96eaf0ea706 (patch) | |
tree | 8c010c14b1815e5f4d56e4790e7965d8d03d6e83 /app | |
parent | 86a2b38479b9942314dc698fb3b798a06bd31ed1 (diff) |
Merge branch '10-2-hashed-storage-file-uploader' into 'master'
FileUploader should use Hashed Storage only when project is migrated
See merge request gitlab-org/gitlab-ce!15526
(cherry picked from commit c63c41afca6d184d22283c2b4f4363bb1ddaaf89)
d087b4da FileUploader should check for hashed_storage?(:attachments) to use disk_path
Diffstat (limited to 'app')
-rw-r--r-- | app/uploaders/file_uploader.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index d4ba3a028be..f4a5cf75018 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -26,11 +26,15 @@ class FileUploader < GitlabUploader # This is used to build Upload paths dynamically based on the model's current # namespace and path, allowing us to ignore renames or transfers. # - # model - Object that responds to `path_with_namespace` + # model - Object that responds to `full_path` and `disk_path` # # Returns a String without a trailing slash - def self.dynamic_path_segment(model) - File.join(CarrierWave.root, base_dir, model.disk_path) + def self.dynamic_path_segment(project) + if project.hashed_storage?(:attachments) + File.join(CarrierWave.root, base_dir, project.disk_path) + else + File.join(CarrierWave.root, base_dir, project.full_path) + end end attr_accessor :model |