Skip to content

FileFields use the same mongo/gridfs collection by default #495

Closed
@deignacio

Description

@deignacio

The gridfs collection_name defaults to 'fs' for all FileFields. This leads to all files being stored in the same place, regardless of Field or Document. This means that there isn't a good way to hook Document.drop_collection() to also clear the referenced files in the gridfs collection.

I propose the following:

  • add a "sandbox files" argument (naming obviously not final) that ensures that the collection names for these file fields are unique.

if this is True, the following things happen:

  • collection_name gets defaulted to <document name>-<field name>-fs
  • runtime errors if a user attempts to override collection_names to the same thing
  • drop_collection() can now safely iterate over gridfs proxied fields bubble drop_collection on those collections

if False:

  • collection_name stays at default to fs
  • add comments in drop collection documentation that explains that you will leak files if you drop_collection()
  • log a bunch of stuff on drop_collection() invocations

I am working on a patch, but wanted to get some feedback on the idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions