Change files to be deleted in batches instead of one-by-one (#23302)
This commit is contained in:
parent
ae30a60b1f
commit
bb4756c823
3 changed files with 114 additions and 29 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue