gitlab-org--gitlab-foss/app/uploaders/artifact_uploader.rb
Stan Hu 8a417f5ae8 Set artifact working directory to be in the destination store to prevent unnecessary I/O
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
2017-06-06 09:51:28 -07:00

39 lines
754 B
Ruby

class ArtifactUploader < GitlabUploader
storage :file
attr_reader :job, :field
def self.local_artifacts_store
Gitlab.config.artifacts.path
end
def self.artifacts_upload_path
File.join(self.local_artifacts_store, 'tmp/uploads/')
end
def initialize(job, field)
@job, @field = job, field
end
def store_dir
default_local_path
end
def cache_dir
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
File.join(self.class.local_artifacts_store, default_path)
end
def default_path
File.join(job.created_at.utc.strftime('%Y_%m'), job.project_id.to_s, job.id.to_s)
end
end