diff options
author | Rosa Gutierrez <rosa@rosapolis.net> | 2017-08-31 17:48:24 +0200 |
---|---|---|
committer | Rosa Gutierrez <rosa@rosapolis.net> | 2017-08-31 18:56:55 +0200 |
commit | 390840eb4e219a26278b88df71ab18b6f8f0fe7a (patch) | |
tree | 112ba8483163013e2d4fa5b84d2d97dcc7c06160 /activestorage/lib/active_storage/service/gcs_service.rb | |
parent | c2b2a8c74fcd2e32996641503ed029c8f7484b00 (diff) | |
download | rails-390840eb4e219a26278b88df71ab18b6f8f0fe7a.tar.gz rails-390840eb4e219a26278b88df71ab18b6f8f0fe7a.tar.bz2 rails-390840eb4e219a26278b88df71ab18b6f8f0fe7a.zip |
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.
Diffstat (limited to 'activestorage/lib/active_storage/service/gcs_service.rb')
-rw-r--r-- | activestorage/lib/active_storage/service/gcs_service.rb | 6 |
1 files changed, 5 insertions, 1 deletions
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 |