I'm using sorl-thumbnail which provides cached thumbnails of a given image. I want to delete generated thumbs when the origin image changes or is deleted. I know that sorl-thumbnail provides a delete method for that case, but..
- it won't be triggered through django-admin
- might be bad cause of race-conditions
- when using a kv store like redis - all data (file connections) might be gone (e.g. reboot)
What fits better is the sorl cleanup management command. This command will delete kv entries with broken origin link and the associated physical thumbs. But what if my kv storage is not complete? I don't want to have dead files lying around.
I thought about a celery task which will trigger the cleanup command and additionally checks all cached files, but don't know how to design that.
What's the best way to detect and cleanup that mess?