Race condition in downsize_upload script


When using the downsize_upload.rb script to shrink uploaded images, some images was changed while the posts that use these images remain unchanged. This could lead to some posts’ images appear like they have disappeared.

Possible Cause

In shrink_uploaded_image.rb , after selecting posts to transform(update image url), there may still be a new post that use the uploaded image. But the new post did not got transformed and use a old reference to a image, like the one in the image above.

Posts that need to be transformed are first selected here:


After this point, any new posts that use the image being transformed will not got their link updated, leading to a broken image.