Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/git_garbage_collect_worker.rb')
-rw-r--r--app/workers/git_garbage_collect_worker.rb19
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