Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-06-12 22:31:00 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2017-06-12 22:31:00 +0300
commitde6c116530ef95e88d3de752c6a1a86b6e6c14f1 (patch)
tree84c561fa51475bf7477f867972568feeca0ad73c /app/uploaders/gitlab_uploader.rb
parent5a66e6d968fb9b1bd1159b9156a88bd06208e363 (diff)
parent8a417f5ae89a509a006bac8a2d6104d8b169782c (diff)
Merge branch 'sh-fix-refactor-uploader-work-dir' into 'master'
Set artifact working directory to be in the destination store to prevent unnecessary I/O Closes #33274 See merge request !11905
Diffstat (limited to 'app/uploaders/gitlab_uploader.rb')
-rw-r--r--app/uploaders/gitlab_uploader.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb
index e4e6d6f46b1..136ec6cc6af 100644
--- a/app/uploaders/gitlab_uploader.rb
+++ b/app/uploaders/gitlab_uploader.rb
@@ -53,4 +53,23 @@ class GitlabUploader < CarrierWave::Uploader::Base
def exists?
file.try(:exists?)
end
+
+ # Override this if you don't want to save files by default to the Rails.root directory
+ def work_dir
+ # Default path set by CarrierWave:
+ # https://github.com/carrierwaveuploader/carrierwave/blob/v1.0.0/lib/carrierwave/uploader/cache.rb#L182
+ CarrierWave.tmp_path
+ end
+
+ private
+
+ # To prevent files from moving across filesystems, override the default
+ # implementation:
+ # http://github.com/carrierwaveuploader/carrierwave/blob/v1.0.0/lib/carrierwave/uploader/cache.rb#L181-L183
+ def workfile_path(for_file = original_filename)
+ # To be safe, keep this directory outside of the the cache directory
+ # because calling CarrierWave.clean_cache_files! will remove any files in
+ # the cache directory.
+ File.join(work_dir, @cache_id, version_name.to_s, for_file)
+ end
end