Skip to content

Chunks not cleaned when removing a file #80

Open

Description

@zedtux

I have already opened the issue carrierwaveuploader/carrierwave-mongoid#205 where I explain that when deleting a model which has a mounter using the :grid_fs storage engine, the GridFs::File is well destroyed, but the belonging GridFs::Chunk aren't, even do I found the has_many :chunks, ..., dependent: :destroy, ... line in this gem.

I have checked the tests from this gem and I couldn't find one which ensures the chunks are cleaned.

Does anyone had that issue already ?

Activity

  1. dblock commented on Oct 18, 2026

    @dblock
    Contributor

    Added a direct GridFS regression in #89: destroying a reloaded file containing multiple chunks removes its file record and all its chunks, while preserving another file and its chunks. This passes on Mongoid 9. The existing dependent-destroy association works in that scenario, so this does not yet reproduce the CarrierWave integration failure.

    file.delete, delete_all, and direct collection deletion skip dependent destruction; file.destroy, GridFs.delete(id), and namespace clear use destruction. Keeping this open pending a reproducible CarrierWave case and the supported-version CI results rather than claiming a fix from a passing direct test.

    Posted by an AI on behalf of @dblock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions