diff options
Diffstat (limited to 'app/uploaders/packages/composer')
-rw-r--r-- | app/uploaders/packages/composer/cache_uploader.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/uploaders/packages/composer/cache_uploader.rb b/app/uploaders/packages/composer/cache_uploader.rb new file mode 100644 index 00000000000..f8052ec4810 --- /dev/null +++ b/app/uploaders/packages/composer/cache_uploader.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true +class Packages::Composer::CacheUploader < GitlabUploader + include ObjectStorage::Concern + + storage_options Gitlab.config.packages + + after :store, :schedule_background_upload + + alias_method :upload, :model + + def filename + "#{model.file_sha256}.json" + end + + def store_dir + dynamic_segment + end + + private + + def dynamic_segment + raise ObjectNotReadyError, 'Package model not ready' unless model.id + + Gitlab::HashedPath.new("packages", "composer_cache", model.namespace_id, root_hash: model.namespace_id) + end +end |