diff options
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/artifact_uploader.rb | 28 | ||||
-rw-r--r-- | app/uploaders/gitlab_uploader.rb | 12 | ||||
-rw-r--r-- | app/uploaders/records_uploads.rb | 4 |
3 files changed, 25 insertions, 19 deletions
diff --git a/app/uploaders/artifact_uploader.rb b/app/uploaders/artifact_uploader.rb index 3e36ec91205..668b6b8e048 100644 --- a/app/uploaders/artifact_uploader.rb +++ b/app/uploaders/artifact_uploader.rb @@ -1,33 +1,31 @@ class ArtifactUploader < GitlabUploader storage :file - attr_accessor :build, :field + attr_reader :job, :field - def self.artifacts_path + def self.local_artifacts_store Gitlab.config.artifacts.path end - def self.artifacts_upload_path - File.join(self.artifacts_path, 'tmp/uploads/') + def initialize(job, field) + @job, @field = job, field end - def self.artifacts_cache_path - File.join(self.artifacts_path, 'tmp/cache/') + def store_dir + default_local_path end - def initialize(build, field) - @build, @field = build, field + def cache_dir + File.join(self.class.local_artifacts_store, 'tmp/cache') end - def store_dir - File.join(self.class.artifacts_path, @build.artifacts_path) - end + private - def cache_dir - File.join(self.class.artifacts_cache_path, @build.artifacts_path) + def default_local_path + File.join(self.class.local_artifacts_store, default_path) end - def filename - file.try(:filename) + def default_path + File.join(job.created_at.utc.strftime('%Y_%m'), job.project_id.to_s, job.id.to_s) end end diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb index e0a6c9b4067..c1d9007dc71 100644 --- a/app/uploaders/gitlab_uploader.rb +++ b/app/uploaders/gitlab_uploader.rb @@ -9,8 +9,16 @@ class GitlabUploader < CarrierWave::Uploader::Base delegate :base_dir, to: :class - def file_storage? - self.class.storage == CarrierWave::Storage::File + def local_file? + local_storage? && file&.is_a?(CarrierWave::SanitizedFile) + end + + def local_storage? + storage.is_a?(CarrierWave::Storage::File) + end + + def local_cache_storage? + cache_storage.is_a?(CarrierWave::Storage::File) end # Reduce disk IO diff --git a/app/uploaders/records_uploads.rb b/app/uploaders/records_uploads.rb index 4c127f29250..be3a2caa60c 100644 --- a/app/uploaders/records_uploads.rb +++ b/app/uploaders/records_uploads.rb @@ -16,7 +16,7 @@ module RecordsUploads # # Called `after :store` def record_upload(_tempfile) - return unless file_storage? + return unless local_file? return unless file.exists? Upload.record(self) @@ -26,7 +26,7 @@ module RecordsUploads # # Called `before :remove` def destroy_upload(*args) - return unless file_storage? + return unless local_file? return unless file Upload.remove_path(relative_path) |