gitlab-org--gitlab-foss/app/uploaders/job_artifact_uploader.rb

35 lines
663 B
Ruby
Raw Normal View History

class JobArtifactUploader < GitlabUploader
2018-01-29 12:57:34 -05:00
extend Workhorse::UploadPath
2018-01-29 12:57:34 -05:00
storage_options Gitlab.config.artifacts
def size
return super if model.size.nil?
model.size
end
def store_dir
2018-01-29 12:57:34 -05:00
dynamic_segment
end
2018-01-25 04:50:56 -05:00
def open
2018-01-26 12:00:29 -05:00
raise 'Only File System is supported' unless file_storage?
2018-01-29 11:56:12 -05:00
File.open(path, "rb") if path
end
private
2018-01-29 12:57:34 -05:00
def dynamic_segment
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