2
0

Fix vacuums being interrupted by a single batch failure (#36606)

This commit is contained in:
Eugen Rochko
2025-10-27 15:22:54 +01:00
committed by GitHub
parent b60bae6361
commit bfcf21e915
2 changed files with 6 additions and 0 deletions

View File

@@ -17,12 +17,16 @@ class Vacuum::MediaAttachmentsVacuum
def vacuum_cached_files! def vacuum_cached_files!
media_attachments_past_retention_period.find_in_batches do |media_attachments| media_attachments_past_retention_period.find_in_batches do |media_attachments|
AttachmentBatch.new(MediaAttachment, media_attachments).clear AttachmentBatch.new(MediaAttachment, media_attachments).clear
rescue => e
Rails.logger.error("Skipping batch while removing cached media attachments due to error: #{e}")
end end
end end
def vacuum_orphaned_records! def vacuum_orphaned_records!
orphaned_media_attachments.find_in_batches do |media_attachments| orphaned_media_attachments.find_in_batches do |media_attachments|
AttachmentBatch.new(MediaAttachment, media_attachments).delete AttachmentBatch.new(MediaAttachment, media_attachments).delete
rescue => e
Rails.logger.error("Skipping batch while removing orphaned media attachments due to error: #{e}")
end end
end end

View File

@@ -16,6 +16,8 @@ class Vacuum::PreviewCardsVacuum
def vacuum_cached_images! def vacuum_cached_images!
preview_cards_past_retention_period.find_in_batches do |preview_card| preview_cards_past_retention_period.find_in_batches do |preview_card|
AttachmentBatch.new(PreviewCard, preview_card).clear AttachmentBatch.new(PreviewCard, preview_card).clear
rescue => e
Rails.logger.error("Skipping batch while removing cached preview cards due to error: #{e}")
end end
end end