-
-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete old print history and time-lapses #762
Comments
Hey, @lettore! Thank you for the feedback. |
@lettore Any specific reason why you want to remove items from the history? Please note that once removed, your print history stats won't be accurate any more. |
I personally don't use Obico for print stats, in fact, I didn't even know that was a thing. For self-hosted, I wipe my Docker host regularly and redeploy from code often and I don't backup the timelapses, so bulk cleaning up the references to videos that don't exist anymore is a win. |
As I print many things everyday my data folder was more than 100GB so it's obvious I need to clean up sometimes the old things I don't need. |
It sounds like the best way to do it is to implement a django admin function to clean up timelapse videos. If you want to get it implemented more quickly and learn something new about django, you can take a stab at it. :) @MallocArray @lettore . An example is https://github.com/TheSpaghettiDetective/obico-server/blob/release/backend/app/management/commands/extract_prints_from_hist.py |
Note that the delete function (whether bulk or individual) and whether in the web or mobile interfaces only deletes the entries from the db.sqlite3 database -- however, the actual jpg, mp4, and json files which can account for tens of gigabytes are NOT deleted. I wrote some bash-sql hacks that address this (and I posted them to the discord group), but here they are: Delete jpg/mp4/json files associated with deleted print history elements
It should be noted that independent of the above there seem to be some "orphan" files that are left in the media/tsd-pics hierarchy that are not referenced in the db.sqlite3 database. These can be cleaned up using the following:
Alternatively, the following also works:
Finally, you can remove empty directories using:
|
Here is some improved code that is FASTER/CLEANER/MORE RELIABLE: Removing images (jpg), video (mp4), and json files for DELETED print history items
Removing ORPHANED files in 'media' hierarchy that are not in the db.sqlite3 database
Alternatively, use the following to calculate ORPHANS
Removing EMPTY directories
|
Here is an updated version now that files are signed with a digest (using DJANGO_SECRET_KEY) Removing images (jpg), video (mp4), and json files for DELETED print history items
Removing ORPHANED files in 'media' hierarchy that are not in the db.sqlite3 database
Alternatively, use the following to calculate ORPHANS:
Removing EMPTY directories
NOTE: Use at your own risk! If you are unsure, you may want to do a test run first by prepending the |
Here is a single bash script that combines all the above scripts along (with confirmations before deleting files)
|
Hello,
Is there a way to delete old time-lapses and print history after x days?
Selecting hundreds of prints in the UI is really a pain, and I want to use a script to remove the old print history automatically.
I already tried to remove the timelapse files but it does not remove the print history and it just leads to a file missing when you try to view or download the file.
The text was updated successfully, but these errors were encountered: