2021-01-29 00:20:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class PurgeDependencyProxyCacheWorker
|
|
|
|
include ApplicationWorker
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
sidekiq_options retry: 3
|
2021-01-29 00:20:46 +05:30
|
|
|
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?
|
|
|
|
|
|
|
|
@group.dependency_proxy_blobs.destroy_all # rubocop:disable Cop/DestroyAll
|
2021-02-22 17:27:13 +05:30
|
|
|
@group.dependency_proxy_manifests.destroy_all # rubocop:disable Cop/DestroyAll
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def valid?
|
|
|
|
return unless @group
|
|
|
|
|
|
|
|
can?(@current_user, :admin_group, @group) && @group.dependency_proxy_feature_available?
|
|
|
|
end
|
|
|
|
end
|