mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Cascade deletion won't delete GridFS file blocks used by FileField

Open StoneMoe opened this issue 3 years ago • 0 comments

GridFS data blocks delete by: https://github.com/MongoEngine/mongoengine/blob/92f6fce77d12f930333bd8980fa611627d3a8d1b/mongoengine/document.py#L642-L644 then https://github.com/MongoEngine/mongoengine/blob/92f6fce77d12f930333bd8980fa611627d3a8d1b/mongoengine/fields.py#L1839-L1844

So calling Document.delete() won't ran into this issue, but cascade delete will, because: https://github.com/MongoEngine/mongoengine/blob/161493c0d24c4f23d4d576f7171e78f0e62cdd70/mongoengine/queryset/base.py#L505-L509 this will call pymongo's delete directly, which will bypass file block delete logic that i referenced above

StoneMoe avatar Nov 30 '20 08:11 StoneMoe