diff options
author | DJ Mountney <david@twkie.net> | 2017-06-08 20:08:06 +0300 |
---|---|---|
committer | DJ Mountney <david@twkie.net> | 2017-06-08 20:08:06 +0300 |
commit | 2afd2fbcb83baaeee8c66859c08b4acff812dccf (patch) | |
tree | 358657d272213da4171c8f04a6adc844bb71b634 /app | |
parent | ae6adf165ce7d9a85d7b8886eefdbe96aac2816b (diff) | |
parent | 1d1363e2bb8a0aee7e2849fd463ea415035710d9 (diff) |
Merge branch 'upstream-9-2-security' into master-security-update
Diffstat (limited to 'app')
-rw-r--r-- | app/uploaders/file_uploader.rb | 7 | ||||
-rw-r--r-- | app/uploaders/gitlab_uploader.rb | 18 |
2 files changed, 21 insertions, 4 deletions
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 7e94218c23d..652277e3b78 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -13,6 +13,13 @@ class FileUploader < GitlabUploader ) end + # Not using `GitlabUploader.base_dir` because all project namespaces are in + # the `public/uploads` dir. + # + def self.base_dir + root_dir + end + # Returns the part of `store_dir` that can change based on the model's current # path # diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb index 02afddb8c6a..489613030e6 100644 --- a/app/uploaders/gitlab_uploader.rb +++ b/app/uploaders/gitlab_uploader.rb @@ -3,16 +3,26 @@ class GitlabUploader < CarrierWave::Uploader::Base File.join(CarrierWave.root, upload_record.path) end - def self.base_dir + def self.root_dir 'uploads' end - delegate :base_dir, to: :class + # When object storage is used, keep the `root_dir` as `base_dir`. + # The files aren't really in folders there, they just have a name. + # The files that contain user input in their name, also contain a hash, so + # the names are still unique + # + # This method is overridden in the `FileUploader` + def self.base_dir + return root_dir unless file_storage? + end - def file_storage? - storage.is_a?(CarrierWave::Storage::File) + def self.file_storage? + self.storage.is_a?(CarrierWave::Storage::File) end + delegate :base_dir, :file_storage?, to: :class + def file_cache_storage? cache_storage.is_a?(CarrierWave::Storage::File) end |