summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-04-26 16:56:14 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-04-26 16:56:14 +0200
commit9f85b7bc58485831a61da0f9acc530511ea7474a (patch)
tree81a9c3345f46415fe44b4ab3e2b3b109d1e4259e /app/workers
parentf127edd012bd8b6f76ac67d69aadbd7d4837258f (diff)
downloadgitlab-ce-9f85b7bc58485831a61da0f9acc530511ea7474a.tar.gz
Initialize wikis on legacy projects during check
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