diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2017-04-28 09:46:15 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-07-20 11:56:52 +0300 |
commit | 72a85ae9ac2468b099a565d3848bf8e0dcdf4499 (patch) | |
tree | 9d95fe450c896cb4b80b19fd247eb5660fde2a2b /app/workers/project_destroy_worker.rb | |
parent | 445cd22c72ca6fbfdcf18d67fa859c4b5b9e2a6c (diff) |
Handle errors while a project is being deleted asynchronously.
1. Rescue all errors that `Projects::DestroyService` might throw, to prevent the
worker from leaving things in an inconsistent state
2. Unmark the project as `pending_delete`
3. Add a `delete_error` text column to `projects`, and save the error message in
there, to be shown to the project masters/owners.
Diffstat (limited to 'app/workers/project_destroy_worker.rb')
-rw-r--r-- | app/workers/project_destroy_worker.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/app/workers/project_destroy_worker.rb b/app/workers/project_destroy_worker.rb index b462327490e..482e1e38cd1 100644 --- a/app/workers/project_destroy_worker.rb +++ b/app/workers/project_destroy_worker.rb @@ -12,5 +12,8 @@ class ProjectDestroyWorker user = User.find(user_id) ::Projects::DestroyService.new(project, user, params.symbolize_keys).execute + rescue StandardError => error + project.assign_attributes(delete_error: error.message, pending_delete: false) + project.save!(validate: false) end end |