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
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,14 @@ 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"
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
def move_dir
......
......@@ -4,6 +4,11 @@ class DeleteUserService
user.errors[:base] << 'You must transfer ownership or delete groups before you can remove user'
user
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
end
end
......
......@@ -6,6 +6,11 @@ class DestroyGroupService
end
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
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