summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-03 15:02:33 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-03 15:02:33 +0000
commitfb59f04fdf9d9417fcf82a24d12f740a7f136cd0 (patch)
tree09dfbdecc527d45876810de2f907293f2465aa0b /app/models/namespace.rb
parent8046b69761b8535726e12319491f2c39305adf3d (diff)
parent55715735d10c3c35e52af6b67c99dcdbb5c7bf97 (diff)
downloadgitlab-ce-fb59f04fdf9d9417fcf82a24d12f740a7f136cd0.tar.gz
Merge branch 'fix-group-remove' into 'master'
Group improvements * remove projects before removing group * execute all hooks/events from project destroy when group removed * log group create/remove * delay remove of namespace directory (to prevent NFS issues) Inspired by !759 See merge request !761
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 211dfa76b81..03d2ab165ea 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -72,7 +72,7 @@ class Namespace < ActiveRecord::Base
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
# Users with the great usernames of "." or ".." would end up with a blank username.
- # Work around that by setting their username to "blank", followed by a counter.
+ # Work around that by setting their username to "blank", followed by a counter.
path = "blank" if path.blank?
counter = 0
@@ -99,7 +99,18 @@ class Namespace < ActiveRecord::Base
end
def rm_dir
- gitlab_shell.rm_namespace(path)
+ # Move namespace directory into trash.
+ # We will remove it later async
+ new_path = "#{path}+#{id}+deleted"
+
+ if gitlab_shell.mv_namespace(path, new_path)
+ message = "Namespace directory \"#{path}\" moved to \"#{new_path}\""
+ Gitlab::AppLogger.info message
+
+ # Remove namespace directroy async with delay so
+ # GitLab has time to remove all projects first
+ GitlabShellWorker.perform_in(5.minutes, :rm_namespace, new_path)
+ end
end
def move_dir