debian-mirror-gitlab/app/uploaders/job_artifact_uploader.rb

36 lines
770 B
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
class JobArtifactUploader < GitlabUploader
extend Workhorse::UploadPath
2018-05-09 12:01:36 +05:30
include ObjectStorage::Concern
ObjectNotReadyError = Class.new(StandardError)
2018-03-17 18:26:18 +05:30
storage_options Gitlab.config.artifacts
2018-10-15 14:42:47 +05:30
def cached_size
return model.size if model.size.present? && !model.file_changed?
2018-03-17 18:26:18 +05:30
2018-10-15 14:42:47 +05:30
size
2018-03-17 18:26:18 +05:30
end
def store_dir
dynamic_segment
end
private
def dynamic_segment
2018-05-09 12:01:36 +05:30
raise ObjectNotReadyError, 'JobArtifact is not ready' unless model.id
2018-03-17 18:26:18 +05:30
creation_date = model.created_at.utc.strftime('%Y_%m_%d')
File.join(disk_hash[0..1], disk_hash[2..3], disk_hash,
creation_date, model.job_id.to_s, model.id.to_s)
end
def disk_hash
@disk_hash ||= Digest::SHA2.hexdigest(model.project_id.to_s)
end
end