summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-06-29 17:43:11 +0000
committerRobert Speicher <robert@gitlab.com>2017-06-29 17:43:11 +0000
commit24972544636ba7c61e41946b5f04c1cd4d4efb26 (patch)
treeb4681ecaa54330cac6bfd7b321b4eef1cb7d47c1 /app
parentd635114b9f03be7be272c0dd6c9ace47eb219483 (diff)
parentfa93156528bca4306e040a1b73720b6411942fcf (diff)
downloadgitlab-ce-24972544636ba7c61e41946b5f04c1cd4d4efb26.tar.gz
Merge branch 'sh-fix-project-destroy-in-namespace' into 'master'
Defer project destroys within a namespace in Groups::DestroyService#async_execute See merge request !12435
Diffstat (limited to 'app')
-rw-r--r--app/models/namespace.rb6
-rw-r--r--app/services/groups/destroy_service.rb3
2 files changed, 7 insertions, 2 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 743e0513e02..672eab94c07 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -219,6 +219,12 @@ class Namespace < ActiveRecord::Base
parent.present?
end
+ def soft_delete_without_removing_associations
+ # We can't use paranoia's `#destroy` since this will hard-delete projects.
+ # Project uses `pending_delete` instead of the acts_as_paranoia gem.
+ self.deleted_at = Time.now
+ end
+
private
def repository_storage_paths
diff --git a/app/services/groups/destroy_service.rb b/app/services/groups/destroy_service.rb
index d40d280140a..80c51cb5a72 100644
--- a/app/services/groups/destroy_service.rb
+++ b/app/services/groups/destroy_service.rb
@@ -1,8 +1,7 @@
module Groups
class DestroyService < Groups::BaseService
def async_execute
- # Soft delete via paranoia gem
- group.destroy
+ group.soft_delete_without_removing_associations
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