Skip to content

A platform for community discussion. Free, open, simple.

FIX: Handle the case where upload goes missing during downsizing

Jarek Radoszcb048d284df6
diff --git a/lib/shrink_uploaded_image.rb b/lib/shrink_uploaded_image.rb
index e5f57eb883a..43416ade0d6 100644
--- a/lib/shrink_uploaded_image.rb
+++ b/lib/shrink_uploaded_image.rb
@@ -28,7 +28,12 @@ class ShrinkUploadedImage
end
# Neither #dup or #clone provide a complete copy
- original_upload = Upload.find(upload.id)
+ original_upload = Upload.find_by(id: upload.id)
+ unless original_upload
+ log "Upload is missing"
+ return false
+ end
+
ww, hh = ImageSizer.resize(w, h)
# A different upload record that matches the sha1 of the downsized image