Skip to content

Commit

Permalink
Update storage mirror task
Browse files Browse the repository at this point in the history
Fix existing integrity errors preventing mirroring of attachments to the
secondary storage services.
  • Loading branch information
gbp committed Mar 28, 2024
1 parent b0d51b7 commit cf6a964
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/tasks/storage/storage.rb
Expand Up @@ -46,7 +46,16 @@ def mirror
count = mirrorable_blobs.count

mirrorable_blobs.find_each.with_index do |blob, index|
mirror_service.mirror(blob.key, checksum: blob.checksum)
begin
mirror_service.mirror(blob.key, checksum: blob.checksum)
rescue ActiveStorage::IntegrityError => ex
raise ex unless @klass == FoiAttachment

# Fix for https://github.com/mysociety/alaveteli/issues/8181
attachment = FoiAttachment.joins(:file_blob).
find_by(active_storage_blobs: { id: blob })
FoiAttachmentMaskJob.perform_later(attachment) # this also mirrors
end

print "#{prefix}: Mirrored #{index + 1}/#{count}"
end
Expand Down

0 comments on commit cf6a964

Please sign in to comment.