Closed zz138960 closed 3 years ago
Hi @zz138960,
This is a bit complicated. So, Wooey keeps a unique copy of a file, known as a WooeyFile
. Each user's job has a pointer to this file known as a UserFile
. This is to minimize the amount of storage required for Wooey, and also was an idea for how we can build in a way for people to share assets with one-another. The next problem is Django actually doesn't delete files referenced by the database, that must be done explicitly.
In anycase, here are two ideas on how to do this properly:
A post_delete
that looks if a WooeyFile
has no known UserFiles
and deletes it if so.
OR
A cron-like-job that does this periodically (preferably calling a cleanup management script so it can be run by any cron-like mechanism).
In short, this doesn't exist at the moment. Are you comfortable using the shell? Something like this would do what you want (I did not test this):
leftovers = WooeyFile.objects.filter(userfile__isnull=True)
for leftover in leftovers:
leftover.filepath.delete()
WooeyFile.objects.filter(userfile__isnull=True).delete()
Thank you for answer.I'll try this method.
Was this sufficient?
Hi, I noticed that related files don't automatically delete after clean-up task has been run,This caused my folder size to get bigger and bigger. Is there any way to improve the situation? Please help me @Chris7 Thank you