Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

ensure service succeeded before deleting associated records

Christophe Bliard09b2ac590dd3
diff --git a/modules/storages/app/services/storages/project_storages/delete_service.rb b/modules/storages/app/services/storages/project_storages/delete_service.rb
index ed18c1b428e..0eb4a553318 100644
--- a/modules/storages/app/services/storages/project_storages/delete_service.rb
+++ b/modules/storages/app/services/storages/project_storages/delete_service.rb
@@ -35,14 +35,9 @@ module Storages::ProjectStorages
# by ::BaseServices::Delete
def persist(service_result)
# Perform the @object.destroy etc. in the super-class
- service_result = super(service_result)
-
- delete_associated_file_links
-
- # Just return the result from the superclass.
- # There is currently no need to incorporate errors from
- # delete_associated_file_links, because it doesn't fail (at the moment).
- service_result
+ super(service_result).tap do |deletion_result|
+ delete_associated_file_links if deletion_result.success?
+ end
end
private