Skip to content

Commit

Permalink
Delete S3 media individually instead of in batches
Browse files Browse the repository at this point in the history
  • Loading branch information
aaga committed Mar 7, 2024
1 parent 35630ba commit 65d83a8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/lib/attachment_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 65d83a8

Please sign in to comment.