FIX: don't raise an error if file not found in S3. (#17841)

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 <regis@hanol.fr>
This commit is contained in:
Vinoth Kannan 2022-08-09 15:16:35 +05:30 committed by GitHub
parent d5dc4ca0e9
commit 169f2ad443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: {})