mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 08:53:41 +08:00
FIX: do not stop fix_missing_s3
task if saving an upload failed (#13658)
This commit logs an error and moves to next upload when saving a single upload record fails when running `uploads:fix_missing_s3` task.
This commit is contained in:
parent
2a1abe9ff0
commit
935aadbfdd
|
@ -1038,16 +1038,20 @@ 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.assign_attributes(etag: fixed_upload.etag, url: fixed_upload.url, verification_status: Upload.verification_statuses[:unchecked])
|
upload.assign_attributes(etag: fixed_upload.etag, url: fixed_upload.url, verification_status: Upload.verification_statuses[:unchecked])
|
||||||
upload.save!(validate: false)
|
saved = upload.save(validate: false)
|
||||||
|
|
||||||
OptimizedImage.where(upload_id: upload.id).destroy_all
|
if saved
|
||||||
rebake_ids = PostUpload.where(upload_id: upload.id).pluck(:post_id)
|
OptimizedImage.where(upload_id: upload.id).destroy_all
|
||||||
|
rebake_ids = PostUpload.where(upload_id: upload.id).pluck(:post_id)
|
||||||
|
|
||||||
if rebake_ids.present?
|
if rebake_ids.present?
|
||||||
Post.where(id: rebake_ids).each do |post|
|
Post.where(id: rebake_ids).each do |post|
|
||||||
puts "rebake post #{post.id}"
|
puts "rebake post #{post.id}"
|
||||||
post.rebake!
|
post.rebake!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
puts "Failed to save upload #{saved.errors.full_messages}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user