diff options
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/artifact_uploader.rb | 4 | ||||
-rw-r--r-- | app/uploaders/gitlab_uploader.rb | 19 | ||||
-rw-r--r-- | app/uploaders/lfs_object_uploader.rb | 12 |
3 files changed, 23 insertions, 12 deletions
diff --git a/app/uploaders/artifact_uploader.rb b/app/uploaders/artifact_uploader.rb index 3bc0408f557..14addb6cf14 100644 --- a/app/uploaders/artifact_uploader.rb +++ b/app/uploaders/artifact_uploader.rb @@ -23,6 +23,10 @@ class ArtifactUploader < GitlabUploader File.join(self.class.local_artifacts_store, 'tmp/cache') end + def work_dir + File.join(self.class.local_artifacts_store, 'tmp/work') + end + private def default_local_path 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 diff --git a/app/uploaders/lfs_object_uploader.rb b/app/uploaders/lfs_object_uploader.rb index 02589959c2f..d11ebf0f9ca 100644 --- a/app/uploaders/lfs_object_uploader.rb +++ b/app/uploaders/lfs_object_uploader.rb @@ -16,16 +16,4 @@ class LfsObjectUploader < GitlabUploader def work_dir File.join(Gitlab.config.lfs.storage_path, 'tmp', 'work') end - - private - - # To prevent LFS 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 |