Closed codezomb closed 12 years ago
I'm not sure I understand what's wrong with after_save
or after_commit
- they are certainly reliable. Pull requests are always welcome though if this is something you'd like to add!
The problem with using after_save, is that from the model level you have zero indication that anything actually happened in the uploader.
Consider the following:
A user has the ability to specify certain filters, or processing that should be done on an uploaded image some time after the original upload occurred.
In the above situation, all versions must be re-processed. After all versions are processed, let's say a notification should be sent out, but this notification only gets sent after all versions have finished processing. Using the after save_method, would need some sort of indicator that all versions are complete. Currently, there is no way to detect this (that I'm aware of).
You could, using after :store set some sort of virtual attribute, something like :processing_complete, or whatever. This causes an issue, that after :store is called after every version is processed and stored. The other solution, would be to track within the uploader, by counter, or other mechanism the versions that have completed. Compare that in your after_save, and send the email as needed.
Both of these solutions are messy, and would greatly benefit from a completion callback of sorts.
I apologize, if I missed something already existing, and given the time would love to submit a patch, I was just hoping something like this existed and/or was already under consideration.
I would like to see this functionality, as well. Have there been any updates on this that you know of?
+1
This would be really useful for deleting tmp directories. I'd like to see an after :processed
callback that runs after all versions have been created.
This would be really useful, unless I'm missing a way to identify which version just launched the current after :store callback.
I need something similar for when recreate_version! is called, I've been looking around if there's a way to know when the recreation finished processing and uploading back to AWS every single recreated version of a file.
+1 Would be very helpful to know an asset is actually available.
I'm not sure if I've just missed it, or what. However, would be nice to have a callback that can be run after all versions are processed, and carrierwave has finished cleaning up. I've used after :store, but it runs after every version, and it makes sense to be able to run some code after all versions have finished processing. after_save in the model isn't reliable, especially since 90% of the use cases are run via background jobs.