From 169f2ad44312c16e667a921a07704657c0aa528b Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Tue, 9 Aug 2022 15:16:35 +0530 Subject: [PATCH] FIX: don't raise an error if file not found in S3. (#17841) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While deleting the object in S3, don't raise an error if the file is not available in S3. Co-authored-by: Régis Hanol --- lib/s3_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/s3_helper.rb b/lib/s3_helper.rb index 111c8b5ce19..859ca462cac 100644 --- a/lib/s3_helper.rb +++ b/lib/s3_helper.rb @@ -97,12 +97,12 @@ class S3Helper # delete the file s3_filename.prepend(multisite_upload_path) if Rails.configuration.multisite delete_object(get_path_for_s3_upload(s3_filename)) - rescue Aws::S3::Errors::NoSuchKey + rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NotFound end def delete_object(key) s3_bucket.object(key).delete - rescue Aws::S3::Errors::NoSuchKey + rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NotFound end def copy(source, destination, options: {})