FIX: Destroy optimized image if attempting to migrate to new scheme fails.

This commit is contained in:
Guo Xiang Tan 2019-03-26 14:37:34 +08:00
parent 0ac6a58b09
commit b58c965aad
1 changed files with 3 additions and 2 deletions

View File

@ -26,9 +26,10 @@ module Jobs
# migrate optimized_images to new scheme
problems = OptimizedImage.migrate_to_new_scheme(50)
problems.each do |hash|
optimized_image_id = hash[:optimized_image].id
Discourse.handle_job_exception(hash[:ex], error_context(args, "Migrating optimized_image id #{optimized_image_id}", optimized_image_id: optimized_image_id))
image = OptimizedImage.find_by(id: hash[:optimized_image].id)
image.destroy! if image
end
end