0
0
Fork 0

Change files to be deleted in batches instead of one-by-one (#23302)

This commit is contained in:
Eugen Rochko 2023-06-26 14:17:41 +02:00 committed by GitHub
parent ae30a60b1f
commit bb4756c823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 114 additions and 29 deletions

View file

@ -15,15 +15,15 @@ class Vacuum::MediaAttachmentsVacuum
private
def vacuum_cached_files!
media_attachments_past_retention_period.find_each do |media_attachment|
media_attachment.file.destroy
media_attachment.thumbnail.destroy
media_attachment.save
media_attachments_past_retention_period.find_in_batches do |media_attachments|
AttachmentBatch.new(MediaAttachment, media_attachments).clear
end
end
def vacuum_orphaned_records!
orphaned_media_attachments.in_batches.destroy_all
orphaned_media_attachments.find_in_batches do |media_attachments|
AttachmentBatch.new(MediaAttachment, media_attachments).delete
end
end
def media_attachments_past_retention_period