Skip to content
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

[feature] Add admin media prune orphaned CLI command #1146

Merged
merged 6 commits into from
Nov 25, 2022

Conversation

tsmethurst
Copy link
Contributor

This PR adds a function to the media manager for pruning orphaned media, where 'orphaned' means media in storage that doesn't have a corresponding database entry.

It also adds a CLI command for invoking that function, which can be run in both dry-run mode (default) or for-real mode.

Results from goblin.technology:

before
---
du -sh storage
9.6G	storage
---

timestamp="25/11/2022 14:05:54.831" func=prune.glob..func1 level=INFO msg=" 5155 stored items were orphaned and pruned"

after
---
du -sh storage
9.2G	storage
---

closes #860

// for each key in the iterator, check if entry is orphaned
log.Info("got %d orphaned pruning candidates, checking for orphaned status, please wait...")
var checkedKeys int
orphanedKeys := make([]string, 0, matchCount)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh i like this use of the match function to build up an approximate slice allocation count :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought you might ;)

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc merged commit 13e9abd into main Nov 25, 2022
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc deleted the prune_orphaned_media_cli_command branch November 25, 2022 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] Clean up orphaned media from storage directory
2 participants