From 390840eb4e219a26278b88df71ab18b6f8f0fe7a Mon Sep 17 00:00:00 2001 From: Rosa Gutierrez Date: Thu, 31 Aug 2017 17:48:24 +0200 Subject: Ignore files already deleted on GCS file deletions Relying on the GET request issued first to fetch the file we want to delete is not enough to avoid this error. If the file is deleted after our GET request but before the DELETE request we'll get a NotFound error that after all means that the file is already deleted, so it can be safely ignored. --- activestorage/lib/active_storage/service/gcs_service.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/activestorage/lib/active_storage/service/gcs_service.rb b/activestorage/lib/active_storage/service/gcs_service.rb index ebf24a36d7..b3fe592097 100644 --- a/activestorage/lib/active_storage/service/gcs_service.rb +++ b/activestorage/lib/active_storage/service/gcs_service.rb @@ -35,7 +35,11 @@ module ActiveStorage def delete(key) instrument :delete, key do - file_for(key).try(:delete) + begin + file_for(key).try(:delete) + rescue Google::Cloud::NotFoundError + # Ignore files already deleted + end end end -- cgit v1.2.3