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

New management command to purge files #14

Open sveetch opened 1 year ago

sveetch commented 1 year ago

As seen in #13 , signals are not always a proper way to purge stale files.

As a new workaround solution, a new command management could be added to analyze objects from database against stored media files to determine if there are stale files to remove or not.

The command won't be a magic thing that will crawl database itself to find stale files, there is just too many possibilities in applications to implement a fully working versions.

At least, we can add a command to launch "purge processors", where each purge processors is dedicated to a model and will know exactly how to work with model attribute and workflow.

A settings for this command would allow to define purge processors for a project. Despite called "purge processor" here, a processor would in fact retrieve used files that will be added to a global list filled from processors. At the end of processors collection, command would list all existing media files and remove all files that have not been collected by processors.

This is still a draft idea, it may need more research and study.

sveetch commented 1 week ago

Note: remember to ensure the documentation correctly notice about compatibility issue between django signal and django cms