-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manage transaction rollback #2209
Manage transaction rollback #2209
Conversation
4ad26be
to
b0ed530
Compare
When we try to create new active record object into transaction and meet rollback: database row will not be created but uploader has created file in folder and doen't remove it. I changed behavior: now we store file only after commit action. This true and for update action in transaction. Changes in spec/orm/activerecord_spec.rb: - add tests which covers this flows - replace cleaning path from 'file path' to 'public_path' folder. Cause folder 'spec/fixtures/uploads ' is not used.
b0ed530
to
665f225
Compare
👍 |
1 similar comment
👍 |
Great work, this will be included in 2.0.0 release! |
In carrierwave 2.0, files are no longer stored in the transaction, meaning this workaround is no longer necessary (see carrierwaveuploader/carrierwave#2209) This reverts commit 10a2744.
I believe this change should be reverted. I'm not saying it doesn't fix the issue it fixes, but it introduces other problems:
Thus, this change can introduce data loss and data corruption. I believe a correct fix for the original issue is to add an |
@fsateler Makes sense, could you open a new issue for that? Or even better if you could work on such an implementation. |
Sure, done at #2545 |
When we try to create new active record object into transaction and meet rollback:
database row will not be created but uploader has created file in folder and doesn't remove it.
I changed behavior: now we store file only after commit action. This true and for update action in transaction.
Changes in spec/orm/activerecord_spec.rb:
- Add tests which covers this flows
- replace cleaning folder from 'file_path' to 'public_path'. Cause file_path is 'spec/fixtures'
and we don't create any 'uploads' folders there. We works with 'spec/public/uploads' folder.