diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/workers/purge_dependency_proxy_cache_worker.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/workers/purge_dependency_proxy_cache_worker.rb')
-rw-r--r-- | app/workers/purge_dependency_proxy_cache_worker.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/workers/purge_dependency_proxy_cache_worker.rb b/app/workers/purge_dependency_proxy_cache_worker.rb new file mode 100644 index 00000000000..594cdd3ed11 --- /dev/null +++ b/app/workers/purge_dependency_proxy_cache_worker.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class PurgeDependencyProxyCacheWorker + include ApplicationWorker + 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 + end + + private + + def valid? + return unless @group + + can?(@current_user, :admin_group, @group) && @group.dependency_proxy_feature_available? + end +end |