Skip to content
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

3.0.2 breaks uploader behavior with rollback and deletes files in remote #2685

Closed
rajyan opened this issue Aug 17, 2023 · 5 comments
Closed

Comments

@rajyan
Copy link
Contributor

rajyan commented Aug 17, 2023

Description

From 3.0.2, carrierwave started to delete files in remote when rollback happens. (which causes a 404 link)

I haven't found the root cause yet, but confirmed that it doesn't happen in 3.0.1.

Still looking for the cause in
#2679

sample code

ActiveRecord::Base.transaction do
  vals.map do |val, i|
    attachment = post.attachments.find(val["id"])
    attachment.some_column = val["col"] # not the mounted column
    attachment.save!
  end
end

post model has a has_many association with attachment model, which mounts a uploader.
when the transaction is rolled back by find or save!, file is deleted for attachment that is saved in the previous iteration.

@rajyan
Copy link
Contributor Author

rajyan commented Aug 17, 2023

I'm trying to create a failing test case right now.

rajyan pushed a commit to rajyan/carrierwave that referenced this issue Aug 17, 2023
files should not be removed on rollback if not updated
rajyan pushed a commit to rajyan/carrierwave that referenced this issue Aug 17, 2023
files should not be removed on rollback if not updated
@rajyan
Copy link
Contributor Author

rajyan commented Aug 17, 2023

I'm trying to create a failing test case right now.

Done. #2686

@rajyan rajyan changed the title 3.0.2 breaks uploader behavior with rollback 3.0.2 breaks uploader behavior with rollback and deletes files in remote Aug 17, 2023
mshibuya added a commit that referenced this issue Aug 17, 2023
@rajyan
Copy link
Contributor Author

rajyan commented Aug 21, 2023

@mshibuya

Could you please cut a new release?
Although we have reverted to 3.0.1 and not affected by this issue now, I believe this issue seems quite critical, because it might delete users files in remote.

@mshibuya
Copy link
Member

You're right, just released 3.0.3.

@rajyan
Copy link
Contributor Author

rajyan commented Aug 21, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants