2020-11-13 21:09:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class PurgeDependencyProxyCacheWorker
|
|
|
|
include ApplicationWorker
|
2021-12-23 15:11:20 +00:00
|
|
|
include DependencyProxy::Expireable
|
2021-04-30 18:10:09 +00:00
|
|
|
|
2021-07-21 12:09:35 +00:00
|
|
|
data_consistency :always
|
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
2020-11-13 21:09:31 +00:00
|
|
|
include Gitlab::Allowable
|
|
|
|
idempotent!
|
|
|
|
|
|
|
|
queue_namespace :dependency_proxy
|
|
|
|
feature_category :dependency_proxy
|
|
|
|
|
|
|
|
def perform(current_user_id, group_id)
|
|
|
|
@current_user = User.find_by_id(current_user_id)
|
|
|
|
@group = Group.find_by_id(group_id)
|
|
|
|
|
|
|
|
return unless valid?
|
|
|
|
|
2021-12-23 15:11:20 +00:00
|
|
|
expire_artifacts(@group.dependency_proxy_blobs)
|
|
|
|
expire_artifacts(@group.dependency_proxy_manifests)
|
2020-11-13 21:09:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def valid?
|
|
|
|
return unless @group
|
|
|
|
|
2021-09-13 18:11:46 +00:00
|
|
|
can?(@current_user, :admin_group, @group)
|
2020-11-13 21:09:31 +00:00
|
|
|
end
|
|
|
|
end
|