summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-12-04 14:10:33 +0100
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-12-04 14:10:33 +0100
commit67a696d5f5a86ad8fa6cc7914106291ce8e908b5 (patch)
tree18d47600b2f22e1c7ff544286e23812a4d7e5801
parent86ec555ac04cea79599799ce3275e785de603004 (diff)
downloadgitlab-ce-git-fsck-worker-client-prep.tar.gz
-rw-r--r--app/workers/repository_check/single_repository_worker.rb1
-rw-r--r--lib/gitlab/git/repository.rb12
2 files changed, 6 insertions, 7 deletions
diff --git a/app/workers/repository_check/single_repository_worker.rb b/app/workers/repository_check/single_repository_worker.rb
index 684bef90553..d07e0192046 100644
--- a/app/workers/repository_check/single_repository_worker.rb
+++ b/app/workers/repository_check/single_repository_worker.rb
@@ -33,6 +33,7 @@ module RepositoryCheck
def git_fsck(repository)
return false unless repository.exists?
+
repository.raw_repository.fsck
true
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 2545c71bc59..865f3d49033 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1119,12 +1119,10 @@ module Gitlab
# Refactoring aid; allows us to copy code from app/models/repository.rb
def run_git(args, env: {}, nice: true)
+ cmd = [Gitlab.config.git.bin_path, *args]
+ cmd.unshift("nice") if nice
circuit_breaker.perform do
- if nice
- popen(["nice", Gitlab.config.git.bin_path, *args], path, env)
- else
- popen([Gitlab.config.git.bin_path, *args], path, env)
- end
+ popen(cmd, path, env)
end
end
@@ -1192,9 +1190,9 @@ module Gitlab
end
def fsck
- ret = run_git(%W[--git-dir=#{path} fsck], nice: true)
+ output, status = run_git(%W[--git-dir=#{path} fsck], nice: true)
- raise GitError.new("command failed: nice git --git-dir=#{path} fsck\n#{ret.first}") unless ret.last.zero?
+ raise GitError.new("Could not fsck repository:\n#{output}") unless status.zero?
end
def gitaly_repository