From 65d83a86c915ce4e35bbbf21f6f319b519b100db Mon Sep 17 00:00:00 2001 From: Ashwin Agarwal Date: Thu, 7 Mar 2024 17:32:09 +0000 Subject: [PATCH] Delete S3 media individually instead of in batches --- app/lib/attachment_batch.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/lib/attachment_batch.rb b/app/lib/attachment_batch.rb index 13a9da828f5cf2..3e0bbb2c4c5f0a 100644 --- a/app/lib/attachment_batch.rb +++ b/app/lib/attachment_batch.rb @@ -95,13 +95,11 @@ def remove_files # objects can be processed at once, so we have to potentially # separate them into multiple calls. - keys.each_slice(LIMIT) do |keys_slice| - logger.debug { "Deleting #{keys_slice.size} objects" } - - bucket.delete_objects(delete: { - objects: keys_slice.map { |key| { key: key } }, - quiet: true, - }) + # Mozilla Social - delete individually instead of in batches, + # since GCP XML API doesn't support batch delete + logger.debug { "Deleting #{keys.size} objects" } + keys.each do |key| + bucket.object(key).delete end end