Feature #20388
Removing attachment after commit transaction
Status: | Closed | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | % Done: | 0% | ||
Category: | Attachments | |||
Target version: | 3.2.0 | |||
Resolution: | Fixed |
Description
Now in Attachment model is
after_destroy :delete_from_disk
If you want to construct a serious logic with Rollback this behaviour leads to remove file from disk, but leave an attachment record in DB.
In my project I replaced this callback on
after_commit :delete_from_disk, on: :destroy
and it works perfect.
I think this is a good modification for Redmine. It have full backward compatibility but can extend ability for strong logic in app.
Associated revisions
Remove attachment after transaction commit (#20388).
Patch by Ivan Zabrovskiy.
History
#1
Updated by Toshi MARUYAMA over 5 years ago
- Target version set to 3.2.0
#2
Updated by Ivan Zabrovskiy over 5 years ago
Notice: in Rails 4 appear new config option related with transaction callbacks:
config.active_record.raise_in_transactional_callbacks = trueIt allows to propagate errors from transaction callbacks. Preferable to turn it on.
#3
Updated by Jean-Philippe Lang over 5 years ago
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Resolution set to Fixed
Change committed in r14630, thanks.