-
Notifications
You must be signed in to change notification settings - Fork 18
Description
When running the purge_old_user_tasks task, the entries are correctly deleted from database, but the files remain orphan on the file system. The code is simply calling the delete() method on the UserTaskStatus model, which in turn deletes the related UserTaskArtifact models by cascading:
django-user-tasks/user_tasks/tasks.py
Line 114 in 9e381de
| UserTaskStatus.objects.filter(created__lt=limit).delete() |
This is most likely related to a change after Django 1.3:
In earlier Django versions, when a model instance containing a FileField was deleted, FileField took it upon itself to also delete the file from the backend storage. This opened the door to several data-loss scenarios, including rolled-back transactions and fields on different models referencing the same file. In Django 1.3, when a model is deleted the FileField’s delete() method won’t be called. If you need cleanup of orphaned files, you’ll need to handle it yourself