diff options
author | George Claghorn <george@basecamp.com> | 2018-07-30 13:13:00 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-07-30 13:13:00 -0400 |
commit | 362042c0d784832d0f5185d7241cf4ae0a300931 (patch) | |
tree | c7e0346aecf9f3dfa7871ae43f99068c420b8946 /activestorage/lib | |
parent | 159e58fc60d612c3d5bd524c9cee0e0922132478 (diff) | |
download | rails-362042c0d784832d0f5185d7241cf4ae0a300931.tar.gz rails-362042c0d784832d0f5185d7241cf4ae0a300931.tar.bz2 rails-362042c0d784832d0f5185d7241cf4ae0a300931.zip |
Ignore concurrently-deleted files when deleting by prefix from GCS
Diffstat (limited to 'activestorage/lib')
-rw-r--r-- | activestorage/lib/active_storage/service/gcs_service.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activestorage/lib/active_storage/service/gcs_service.rb b/activestorage/lib/active_storage/service/gcs_service.rb index fdde01d4a3..3cfcb778a2 100644 --- a/activestorage/lib/active_storage/service/gcs_service.rb +++ b/activestorage/lib/active_storage/service/gcs_service.rb @@ -61,7 +61,13 @@ module ActiveStorage def delete_prefixed(prefix) instrument :delete_prefixed, prefix: prefix do - bucket.files(prefix: prefix).all(&:delete) + bucket.files(prefix: prefix).all do |file| + begin + file.delete + rescue Google::Cloud::NotFoundError + # Ignore concurrently-deleted files + end + end end end |