jstorimer/delayed_paperclip — Issue #50: Paperclip would not delete original file if attachment_processing=true
Author: cryo28
Created: 2011-11-16 18:44:17+00:00
State: open

Paperclip uses Paperclip::Attachment#most_appropriate_url when populating @queue_for_delete with filenames to be deleted if a instance with attachment is destroyed.

However this method is overriden by delayed_paperclip.

In case of

* A new attachment is assigned to model instance
* model is saved (:original style file is stored at the location specified by :path) and a new job to make styles is put into resque queue
* The model is attempted to be destroyed when worker has not yet generated styles (attachment_processing=true)

Paperclip will not delete original-style file because #most_appropriate_url will return the missing.png url. (I'd like to focus, the instance is not dirty, has an id, file is stored at its correct location, but attachment_processing=true).

This orphaned original-style file will be on stored filesystem forever (untill it is manually removed).

Probably Paperclip::Attachment#url should be also overriden to pass style_name attribute to most_appropriate_url, which would return correct interpolation string if the instance is not dirty and requested style is :original.