sveetch / django-smart-media

Django file fields with SVG support
https://django-smart-media.readthedocs.io/en/latest/
MIT License
1 stars 0 forks source link

Add a warning about signals in documentation #13

Closed sveetch closed 1 year ago

sveetch commented 1 year ago

It has been proved at least the receiver auto_purge_files_on_delete connected on post_delete signal can be harmful when used with some very specific models.

This is especially the case with model from an application that may clone objects and delete original. As a example, there is a plugin from DjangoCMS, during publishing a page where a plugin has changed, the original plugin object from draft is cloned and original is removed.

The problem is that cloned object has copied the media paths but the original one is deleted so the auto_purge_files_on_delete delete its media since it don't know the media is still used from cloned object.

From implementation of auto_purge_files_on_delete it won't never been able to manage these specific case, developer should have to implement a new receiver which could manage it. But in the DjangoCMS plugin case, there is just not any argument passed to receiver that would allow to manage it well.

Signals should have a clear warning about these situation so developer could know about it possible problems before to add it into their applications.

sveetch commented 1 year ago

Done in 0.3.1-pre.2