Carrierwave only deletes the 'mounted' file after the object in the database has been removed:
after_commit :remove_avatar! :on => :destroy
I'm implementing a BackgroundDestroyable concern and for this I have a worker deleting the files.
The deleted_at
field registers when the object was marked for complete removal and to ensure that objects are only actually removed by the worker I needed to reset the destroy
on concern.
If one of the workers receives a timeout I lose the reference of my orphaned files in S3, since my objects in the database have been deleted.
What should I do to make sure I will not be orphaned in S3?
Call remove_avatar!
direct before object.destroy
and then skip_callback?
Is it safe to do this?