diff options
Diffstat (limited to 'app/workers/packages')
-rw-r--r-- | app/workers/packages/composer/cache_cleanup_worker.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/workers/packages/composer/cache_cleanup_worker.rb b/app/workers/packages/composer/cache_cleanup_worker.rb new file mode 100644 index 00000000000..638e50e18c4 --- /dev/null +++ b/app/workers/packages/composer/cache_cleanup_worker.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Packages + module Composer + class CacheCleanupWorker + include ApplicationWorker + include CronjobQueue # rubocop:disable Scalability/CronWorkerContext + + feature_category :package_registry + + idempotent! + + def perform + ::Packages::Composer::CacheFile.without_namespace.find_in_batches do |cache_files| + cache_files.each(&:destroy) + rescue ActiveRecord::RecordNotFound + # ignore. likely due to object already being deleted. + end + + ::Packages::Composer::CacheFile.expired.find_in_batches do |cache_files| + cache_files.each(&:destroy) + rescue ActiveRecord::RecordNotFound + # ignore. likely due to object already being deleted. + end + rescue => e + Gitlab::ErrorTracking.log_exception(e) + end + end + end +end |