debian-mirror-gitlab/app/services/groups/destroy_service.rb

29 lines
980 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
module Groups
class DestroyService < Groups::BaseService
def async_execute
job_id = GroupDestroyWorker.perform_async(group.id, current_user.id)
Rails.logger.info("User #{current_user.id} scheduled a deletion of group ID #{group.id} with job ID #{job_id}")
end
def execute
group.prepare_for_destroy
2017-09-10 17:25:29 +05:30
group.projects.each do |project|
2017-08-17 22:00:37 +05:30
# Execute the destruction of the models immediately to ensure atomic cleanup.
# Skip repository removal because we remove directory with namespace
# that contain all these repositories
2018-03-17 18:26:18 +05:30
::Projects::DestroyService.new(project, current_user, skip_repo: project.legacy_storage?).execute
2017-08-17 22:00:37 +05:30
end
group.children.each do |group|
# This needs to be synchronous since the namespace gets destroyed below
DestroyService.new(group, current_user).execute
end
2017-09-10 17:25:29 +05:30
group.chat_team&.remove_mattermost_team(current_user)
2018-03-17 18:26:18 +05:30
group.destroy
2017-08-17 22:00:37 +05:30
end
end
end