From b7fdd82409fdb7e3b306d2ee7d34ef6f8d6e0173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Zrim=C5=A1ek?= Date: Thu, 8 Nov 2018 21:19:17 +0100 Subject: [PATCH] Ensure temp files deletion after export is done [SCI-2646] --- app/models/team_zip_export.rb | 7 +++---- app/models/zip_export.rb | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) 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