Commit 1edff534 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove projects before group/user. Remove namespace directory async

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 61cfd1d2
...@@ -72,7 +72,7 @@ class Namespace < ActiveRecord::Base ...@@ -72,7 +72,7 @@ class Namespace < ActiveRecord::Base
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "") path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
# Users with the great usernames of "." or ".." would end up with a blank username. # 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? path = "blank" if path.blank?
counter = 0 counter = 0
...@@ -99,7 +99,14 @@ class Namespace < ActiveRecord::Base ...@@ -99,7 +99,14 @@ class Namespace < ActiveRecord::Base
end end
def rm_dir def rm_dir
gitlab_shell.rm_namespace(path) # Move namespace directory into trash.
# We will remove it later async
new_path = "#{path}+#{id}+deleted"
gitlab_shell.mv_namespace(path, new_path)
# 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 def move_dir
......
...@@ -4,6 +4,11 @@ class DeleteUserService ...@@ -4,6 +4,11 @@ class DeleteUserService
user.errors[:base] << 'You must transfer ownership or delete groups before you can remove user' user.errors[:base] << 'You must transfer ownership or delete groups before you can remove user'
user user
else else
# TODO: Skip remove repository so Namespace#rm_dir works
user.personal_projects.each do |project|
::Projects::DestroyService.new(project, current_user, {}).execute
end
user.destroy user.destroy
end end
end end
......
...@@ -6,6 +6,11 @@ class DestroyGroupService ...@@ -6,6 +6,11 @@ class DestroyGroupService
end end
def execute def execute
# TODO: Skip remove repository so Namespace#rm_dir works
@group.projects.each do |project|
::Projects::DestroyService.new(project, current_user, {}).execute
end
@group.destroy @group.destroy
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment