Commit 1fe45898d7871512bb25b5c314301221420c560b
1 parent
7ded8584
Exists in
master
and in
4 other branches
Fix deletion of tmp/gitlabhq-gitolite* folders in a NFS environment.
When working inside of a Vagrant box with NFS enabled, the deletion of a repository in tmp/ doesn't work every time. It is related to NFS inability to delete a folder if it's still used by a resource (e.g. `rm -rf ./folder` would leave the folder and a .nfs* file in it). In this case it's the temporary repository which can't be deleted because `ga_repo` is still using it. De-allocating ga_repo is not possible (thanks Ruby), but deleting the folder it points to in the first place fixes the issue. Reference: http://stackoverflow.com/questions/11228079/python-remove-directory-error-file-exists
Showing
1 changed file
with
9 additions
and
5 deletions
Show diff stats
lib/gitlab/backend/gitolite_config.rb
@@ -40,18 +40,22 @@ module Gitlab | @@ -40,18 +40,22 @@ module Gitlab | ||
40 | 40 | ||
41 | # Save changes in | 41 | # Save changes in |
42 | # gitolite-admin repo | 42 | # gitolite-admin repo |
43 | - # before pusht it | 43 | + # before push it |
44 | ga_repo.save | 44 | ga_repo.save |
45 | 45 | ||
46 | # Push gitolite-admin repo | 46 | # Push gitolite-admin repo |
47 | # to apply all changes | 47 | # to apply all changes |
48 | push(config_tmp_dir) | 48 | push(config_tmp_dir) |
49 | - | 49 | + ensure |
50 | # Remove tmp dir | 50 | # Remove tmp dir |
51 | - # wiith gitolite-admin | 51 | + # removing the gitolite folder first is important to avoid |
52 | + # NFS issues. | ||
53 | + FileUtils.rm_rf(File.join(config_tmp_dir, 'gitolite')) | ||
54 | + | ||
55 | + # Remove parent tmp dir | ||
52 | FileUtils.rm_rf(config_tmp_dir) | 56 | FileUtils.rm_rf(config_tmp_dir) |
53 | - ensure | ||
54 | - # unlock so other task cann access | 57 | + |
58 | + # Unlock so other task can access | ||
55 | # gitolite configuration | 59 | # gitolite configuration |
56 | f.flock(File::LOCK_UN) | 60 | f.flock(File::LOCK_UN) |
57 | end | 61 | end |