diff options
author | Stan Hu <stanhu@gmail.com> | 2016-08-06 17:25:51 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-08-10 19:28:21 +0300 |
commit | 4955a47cb1c52168114364e45a2fccf6bc105452 (patch) | |
tree | 50bb5ea1979a596edef53817aea75796686fc2a9 /app/services/projects | |
parent | ae2d3c417075c83e169ab7662f3dd11e3b2bf043 (diff) |
Clean up project destruction
Instead of redirecting from the project service to the service and back to the model,
put all destruction code in the service. Also removes a possible source of failure
where run_after_commit may not destroy the project.
Diffstat (limited to 'app/services/projects')
-rw-r--r-- | app/services/projects/destroy_service.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index 882606e38d0..8a53f65aec1 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -6,8 +6,12 @@ module Projects DELETED_FLAG = '+deleted' - def pending_delete! - project.schedule_delete!(current_user.id, params) + def async_execute + project.transaction do + project.update_attribute(:pending_delete, true) + job_id = ProjectDestroyWorker.perform_async(project.id, current_user.id, params) + Rails.logger.info("User #{current_user.id} scheduled destruction of project #{project.path_with_namespace} with job ID #{job_id}") + end end def execute |