summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-05-09 12:19:33 +0200
committerJames Lopez <james@jameslopez.es>2016-05-09 12:19:33 +0200
commit3f87387b6f82187a96c9fea797783169ca3c2a03 (patch)
tree51183c64155cabfdcec4770e1f0a2064a771841d /app/workers
parent9c639041fe312f8edf1613809ac665cb8755ffb7 (diff)
parent90ae445ba930068d04adc5a009dbdeabe4cb3e34 (diff)
downloadgitlab-ce-3f87387b6f82187a96c9fea797783169ca3c2a03.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export
# Conflicts: # app/models/project.rb
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/repository_check/single_repository_worker.rb34
1 files changed, 23 insertions, 11 deletions
diff --git a/app/workers/repository_check/single_repository_worker.rb b/app/workers/repository_check/single_repository_worker.rb
index a76729e3c74..f2d12ba5a7d 100644
--- a/app/workers/repository_check/single_repository_worker.rb
+++ b/app/workers/repository_check/single_repository_worker.rb
@@ -1,9 +1,9 @@
module RepositoryCheck
class SingleRepositoryWorker
include Sidekiq::Worker
-
+
sidekiq_options retry: false
-
+
def perform(project_id)
project = Project.find(project_id)
project.update_columns(
@@ -11,20 +11,32 @@ module RepositoryCheck
last_repository_check_at: Time.now,
)
end
-
+
private
-
+
def check(project)
- repositories = [project.repository]
- repositories << project.wiki.repository if project.wiki_enabled?
- # Use 'map do', not 'all? do', to prevent short-circuiting
- repositories.map { |repository| git_fsck(repository.path_to_repo) }.all?
+ if !git_fsck(project.repository)
+ false
+ elsif project.wiki_enabled?
+ # Historically some projects never had their wiki repos initialized;
+ # this happens on project creation now. Let's initialize an empty repo
+ # if it is not already there.
+ begin
+ project.create_wiki
+ rescue Rugged::RepositoryError
+ end
+
+ git_fsck(project.wiki.repository)
+ else
+ true
+ end
end
-
- def git_fsck(path)
+
+ def git_fsck(repository)
+ path = repository.path_to_repo
cmd = %W(nice git --git-dir=#{path} fsck)
output, status = Gitlab::Popen.popen(cmd)
-
+
if status.zero?
true
else