diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 7 | ||||
-rw-r--r-- | app/services/projects/destroy_service.rb | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 9403acf7759..dfd1e54ecf7 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1039,4 +1039,11 @@ class Project < ActiveRecord::Base def wiki @wiki ||= ProjectWiki.new(self, self.owner) end + + def schedule_delete!(user_id, params) + # Queue this task for after the commit, so once we mark pending_delete it will run + run_after_commit { ProjectDestroyWorker.perform_async(id, user_id, params) } + + update_attribute(:pending_delete, true) + end end diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index df5054f08d7..19aab999e00 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -7,9 +7,7 @@ module Projects DELETED_FLAG = '+deleted' def pending_delete! - project.update_attribute(:pending_delete, true) - - ProjectDestroyWorker.perform_in(1.minute, project.id, current_user.id, params) + project.schedule_delete!(current_user.id, params) end def execute |