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/git_garbage_collect_worker.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/workers/git_garbage_collect_worker.rb')
-rw-r--r-- | app/workers/git_garbage_collect_worker.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/app/workers/git_garbage_collect_worker.rb b/app/workers/git_garbage_collect_worker.rb index 9071e4b8a1b..e1dcb16bafb 100644 --- a/app/workers/git_garbage_collect_worker.rb +++ b/app/workers/git_garbage_collect_worker.rb @@ -27,15 +27,15 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker task = task.to_sym - if task == :gc + if gc?(task) ::Projects::GitDeduplicationService.new(project).execute cleanup_orphan_lfs_file_references(project) end - gitaly_call(task, project.repository.raw_repository) + gitaly_call(task, project) # Refresh the branch cache in case garbage collection caused a ref lookup to fail - flush_ref_caches(project) if task == :gc + flush_ref_caches(project) if gc?(task) update_repository_statistics(project) if task != :pack_refs @@ -48,6 +48,10 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker private + def gc?(task) + task == :gc || task == :prune + end + def try_obtain_lease(key) ::Gitlab::ExclusiveLease.new(key, timeout: LEASE_TIMEOUT).try_obtain end @@ -64,8 +68,9 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker ::Gitlab::ExclusiveLease.get_uuid(key) end - ## `repository` has to be a Gitlab::Git::Repository - def gitaly_call(task, repository) + def gitaly_call(task, project) + repository = project.repository.raw_repository + client = if task == :pack_refs Gitlab::GitalyClient::RefService.new(repository) else @@ -73,8 +78,8 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker end case task - when :gc - client.garbage_collect(bitmaps_enabled?) + when :prune, :gc + client.garbage_collect(bitmaps_enabled?, prune: task == :prune) when :full_repack client.repack_full(bitmaps_enabled?) when :incremental_repack |