summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-05-09 18:01:06 +0200
committerJames Lopez <james@jameslopez.es>2016-05-09 18:01:06 +0200
commit47cd14b560e67c6d3641828ac36b1e0cb9285c6e (patch)
tree668ed7b5d39c816f8cfad775688ec2f5a083d6af /app/workers
parent49cdb778a17b25014c9439eb1a719e1fac9d04d0 (diff)
parent7ff2a51eb24032895e6199c62de44e17de65af7b (diff)
downloadgitlab-ce-47cd14b560e67c6d3641828ac36b1e0cb9285c6e.tar.gz
Merge branch 'feature/project-export' of gitlab.com:gitlab-org/gitlab-ce into feature/project-import
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