I'm trying to skip PaperClip
process if my music has been deleted.
Basically when I upload a music, I want to destroy every single piece of this uploaded file if something went wrong. This operation is delayed and done by ffmpeg
. Another task is delayed to attached picture to my music.
Unfortunately, PaperClip
process (to attach the picture) has already been delayed when I destroy bad musics. This means when the process starts the source doesn't exist anymore.
This blocks my delayed_jobs
and I have to destroy it manually.
I'm using Delayed_paperclip to create those delayed jobs.
How can I check if the source exists before processing?
The issue you are dealing with is called
race condition
: https://en.wikipedia.org/wiki/Race_conditionAssuming, you are donig something like:
@my_instance.delay.method
You might want to pass the id of the object you are attaching an image to it to a
perform
methodExample: https://github.com/collectiveidea/delayed_job/#custom-jobs