Commit b994a65fc318a91458fa8bb219e7ce07bd893eb5

Authored by randx
1 parent 79021e67

change gitolite backend behaviour to prevent error when config directory removed

lib/gitlab/backend/gitolite.rb
... ... @@ -5,7 +5,7 @@ module Gitlab
5 5 class AccessDenied < StandardError; end
6 6  
7 7 def config
8   - @config ||= Gitlab::GitoliteConfig.new
  8 + Gitlab::GitoliteConfig.new
9 9 end
10 10  
11 11 def set_key key_id, key_content, projects
... ...
lib/gitlab/backend/gitolite_config.rb
... ... @@ -4,8 +4,10 @@ require &#39;fileutils&#39;
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
... ...