diff --git a/app/models/team_zip_export.rb b/app/models/team_zip_export.rb index 2ee99cc58..279dab009 100644 --- a/app/models/team_zip_export.rb +++ b/app/models/team_zip_export.rb @@ -30,10 +30,9 @@ class TeamZipExport < ZipExport fill_content(dir_to_zip, data, type, options) zip!(dir_to_zip, output_file.path) self.zip_file = File.open(output_file) - if save - FileUtils.rm_rf([dir_to_zip, output_file], secure: true) - generate_notification(user) - end + generate_notification(user) if save + ensure + FileUtils.rm_rf([dir_to_zip, output_file], secure: true) end handle_asynchronously :generate_exportable_zip diff --git a/app/models/zip_export.rb b/app/models/zip_export.rb index f84633b9c..0c699726d 100644 --- a/app/models/zip_export.rb +++ b/app/models/zip_export.rb @@ -60,10 +60,9 @@ class ZipExport < ApplicationRecord fill_content(dir_to_zip, data, type, options) zip!(dir_to_zip, output_file.path) self.zip_file = File.open(output_file) - if save - FileUtils.rm_rf([dir_to_zip, output_file], secure: true) - generate_notification(user) - end + generate_notification(user) if save + ensure + FileUtils.rm_rf([dir_to_zip, output_file], secure: true) end handle_asynchronously :generate_exportable_zip