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
@@ -5,7 +5,7 @@ module Gitlab | @@ -5,7 +5,7 @@ module Gitlab | ||
5 | class AccessDenied < StandardError; end | 5 | class AccessDenied < StandardError; end |
6 | 6 | ||
7 | def config | 7 | def config |
8 | - @config ||= Gitlab::GitoliteConfig.new | 8 | + Gitlab::GitoliteConfig.new |
9 | end | 9 | end |
10 | 10 | ||
11 | def set_key key_id, key_content, projects | 11 | def set_key key_id, key_content, projects |
lib/gitlab/backend/gitolite_config.rb
@@ -4,8 +4,10 @@ require 'fileutils' | @@ -4,8 +4,10 @@ require 'fileutils' | ||
4 | 4 | ||
5 | module Gitlab | 5 | module Gitlab |
6 | class GitoliteConfig | 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 | end | 11 | end |
10 | 12 | ||
11 | def apply | 13 | def apply |
@@ -13,9 +15,11 @@ module Gitlab | @@ -13,9 +15,11 @@ module Gitlab | ||
13 | File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f| | 15 | File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f| |
14 | begin | 16 | begin |
15 | f.flock(File::LOCK_EX) | 17 | f.flock(File::LOCK_EX) |
18 | + reset_config_tmp_dir | ||
16 | pull | 19 | pull |
17 | yield(self) | 20 | yield(self) |
18 | push | 21 | push |
22 | + FileUtils.rm_rf(config_tmp_dir) | ||
19 | ensure | 23 | ensure |
20 | f.flock(File::LOCK_UN) | 24 | f.flock(File::LOCK_UN) |
21 | end | 25 | end |
@@ -160,8 +164,6 @@ module Gitlab | @@ -160,8 +164,6 @@ module Gitlab | ||
160 | `git commit -am "GitLab"` | 164 | `git commit -am "GitLab"` |
161 | `git push` | 165 | `git push` |
162 | Dir.chdir(Rails.root) | 166 | Dir.chdir(Rails.root) |
163 | - | ||
164 | - FileUtils.rm_rf(config_tmp_dir) | ||
165 | end | 167 | end |
166 | end | 168 | end |
167 | end | 169 | end |