Commit b994a65fc318a91458fa8bb219e7ce07bd893eb5
1 parent
79021e67
Exists in
master
and in
4 other branches
change gitolite backend behaviour to prevent error when config directory removed
Showing
2 changed files
with
7 additions
and
5 deletions
Show diff stats
lib/gitlab/backend/gitolite.rb
lib/gitlab/backend/gitolite_config.rb
... | ... | @@ -4,8 +4,10 @@ require 'fileutils' |
4 | 4 | |
5 | 5 | module Gitlab |
6 | 6 | class GitoliteConfig |
7 | - def config_tmp_dir | |
8 | - @config_tmp_dir ||= File.join(Rails.root, 'tmp',"gitlabhq-gitolite-#{Time.now.to_i}") | |
7 | + attr_reader :config_tmp_dir | |
8 | + | |
9 | + def reset_config_tmp_dir | |
10 | + @config_tmp_dir = File.join(Rails.root, 'tmp',"gitlabhq-gitolite-#{Time.now.to_i}") | |
9 | 11 | end |
10 | 12 | |
11 | 13 | def apply |
... | ... | @@ -13,9 +15,11 @@ module Gitlab |
13 | 15 | File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f| |
14 | 16 | begin |
15 | 17 | f.flock(File::LOCK_EX) |
18 | + reset_config_tmp_dir | |
16 | 19 | pull |
17 | 20 | yield(self) |
18 | 21 | push |
22 | + FileUtils.rm_rf(config_tmp_dir) | |
19 | 23 | ensure |
20 | 24 | f.flock(File::LOCK_UN) |
21 | 25 | end |
... | ... | @@ -160,8 +164,6 @@ module Gitlab |
160 | 164 | `git commit -am "GitLab"` |
161 | 165 | `git push` |
162 | 166 | Dir.chdir(Rails.root) |
163 | - | |
164 | - FileUtils.rm_rf(config_tmp_dir) | |
165 | 167 | end |
166 | 168 | end |
167 | 169 | end | ... | ... |