FEATURE: ensure posts are rebaked when missing is fixed

This ensures any corrupt optimized images are removed and re-created
This commit is contained in:
Sam Saffron 2020-08-18 15:37:11 +10:00
parent bb74ccf288
commit 24fe08230f
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
1 changed files with 10 additions and 0 deletions

View File

@ -1092,6 +1092,16 @@ def fix_missing_s3
# we do not fix sha, it may be wrong for arbitrary reasons, if we correct it # we do not fix sha, it may be wrong for arbitrary reasons, if we correct it
# we may end up breaking posts # we may end up breaking posts
upload.update!(etag: fixed_upload.etag, url: fixed_upload.url, verified: nil) upload.update!(etag: fixed_upload.etag, url: fixed_upload.url, verified: nil)
OptimizedImage.where(upload_id: upload.id).destroy_all
rebake_ids = PostUpload.where(upload_id: upload.id).pluck(:post_id)
if rebake_ids.present?
Post.where(id: rebake_ids).each do |post|
puts "rebake post #{post.id}"
post.rebake!
end
end
end end
end end