2020-07-08 08:09:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
class Packages::PackageFileUploader < GitlabUploader
|
|
|
|
extend Workhorse::UploadPath
|
|
|
|
include ObjectStorage::Concern
|
|
|
|
|
|
|
|
storage_options Gitlab.config.packages
|
|
|
|
|
|
|
|
after :store, :schedule_background_upload
|
|
|
|
|
|
|
|
alias_method :upload, :model
|
|
|
|
|
|
|
|
def filename
|
|
|
|
model.file_name
|
|
|
|
end
|
|
|
|
|
|
|
|
def store_dir
|
|
|
|
dynamic_segment
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def dynamic_segment
|
2020-11-02 16:09:10 -05:00
|
|
|
raise ObjectNotReadyError, "Package model not ready" unless model.id
|
|
|
|
|
2020-08-07 14:09:53 -04:00
|
|
|
Gitlab::HashedPath.new('packages', model.package.id, 'files', model.id, root_hash: model.package.project_id)
|
2020-07-08 08:09:33 -04:00
|
|
|
end
|
|
|
|
end
|