From 362042c0d784832d0f5185d7241cf4ae0a300931 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Mon, 30 Jul 2018 13:13:00 -0400 Subject: Ignore concurrently-deleted files when deleting by prefix from GCS --- activestorage/lib/active_storage/service/gcs_service.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'activestorage/lib') 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 -- cgit v1.2.3