diff options
author | Stan Hu <stanhu@gmail.com> | 2017-06-04 22:12:18 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-06-06 09:51:28 -0700 |
commit | 8a417f5ae89a509a006bac8a2d6104d8b169782c (patch) | |
tree | 3bc284f60f3cb7bccad319891a38f947c62c4812 /app/uploaders/gitlab_uploader.rb | |
parent | 6ac1caa01a4c059f5bcb7c9da2e83001e5469f73 (diff) | |
download | gitlab-ce-8a417f5ae89a509a006bac8a2d6104d8b169782c.tar.gz |
Set artifact working directory to be in the destination store to prevent unnecessary I/Osh-fix-refactor-uploader-work-dir
Similar to #33218, build artifacts were being uploaded into a CarrierWave
temporary directory in the Rails root directory before moved to their
final destination, which could cause a copy across filesystems. This
merge request refactors the work in !11866 so that any uploader can
just override `work_dir` to change the default implementation.
Closes #33274
Diffstat (limited to 'app/uploaders/gitlab_uploader.rb')
-rw-r--r-- | app/uploaders/gitlab_uploader.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb index 02afddb8c6a..ea3037e9bd8 100644 --- a/app/uploaders/gitlab_uploader.rb +++ b/app/uploaders/gitlab_uploader.rb @@ -41,4 +41,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 |