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

Chunks not cleaned when removing a file #205

Open
zedtux opened this issue Oct 20, 2022 · 1 comment
Open

Chunks not cleaned when removing a file #205

zedtux opened this issue Oct 20, 2022 · 1 comment

Comments

@zedtux
Copy link

zedtux commented Oct 20, 2022

We are facing a database size increase in our MongoDB 5 server since we've upgraded some gems including this one from our Rails 6.1 application.

Basically, when deleting a model that has a Carrierwave mounter with the :grid_fs storage engine, it destroys the GridFs::File but not the associated GridFs::Chunk.

I can't find any test from this gem checking for the cleaning of the chunks since, I guess, it's up to the mongoid-grid_fs gem to take care of it.

Have anyone experienced this issue ?

@ZiuzkinAliaksandr
Copy link

ZiuzkinAliaksandr commented Dec 22, 2023

Hi! To fix this issue and destroy associated chunks together with file i added monkey patch for delete method

module CarrierWave
  module Storage
    class GridFS
      class File
        def delete
          grid_file.destroy if grid_file
        end
      end
    end # GridFS
  end # Storage
end # CarrierWave

cc @zedtux

P.S. this patch also fixed for me issue with producing of orphan chunks.

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