Feature/sweep until - #303
Conversation
You can now set a sweep_until_gb_free or sweep_until_percent_used option in each library to only cleanup media if your available storage drops below a certain mark. This respects all existing filter.
There was a problem hiding this comment.
Pull request overview
Adds per-library “sweep until” limits to cap how many items get queued for deletion in a cleanup run, targeting a desired disk state (percent used or GB free) to avoid over-queuing on large/shared disks.
Changes:
- Introduces
sweep_until_percent_usedandsweep_until_gb_freelibrary config options. - Implements
applySweepUntilLimitto compute per-filesystem deletion budgets using live disk stats and already-pending DB items. - Updates README to document the new sweep-until behavior and configuration examples.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
internal/engine/engine.go |
Adds sweep-until limiting logic and integrates it into the mark-for-deletion pipeline. |
internal/config/config.go |
Adds new per-library configuration fields for sweep-until targets. |
README.md |
Documents sweep-until feature, options, and examples; updates TOC/feature list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
have tested the following cleanup_mode modes:
The few tests i have done with these modes seems to work as i would expect them to. With setting keep_count to 1 and 10, changed the number of items marked for clean up massively - and the GB estimated to be cleaned up looks to be about right. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Latest tests (via
|
| Cleanup Mode | Keep Count | Est. GB Freed (via stats dashboard) | Item Count |
|---|---|---|---|
| all | 1 | 889 | 21 |
| keep_episodes | 10 | 891 | 19 |
| keep_seasons | 1 | 892 | 9 |
sweep_until_percent_used: 60
| Cleanup Mode | Keep Count | Est. GB Freed (via stats dashboard) | Item Count |
|---|---|---|---|
| all | 10 | ~3000 | 64 |
| keep_episodes | 10 | ~3000 | 110 |
| keep_seasons | 1 | ~3000 | 96 |
Currently free: 13935 GB
sweep_until_gb_free: 14000
| Cleanup Mode | Keep Count | Est. GB Freed (via stats dashboard) | Item Count |
|---|---|---|---|
| all | 10 | 66 | 6 |
| keep_episodes | 10 | 67 | 13 |
| keep_seasons | 1 | 66 | 3 |
sweep_until_gb_free: 15500
| Cleanup Mode | Keep Count | Est. GB Freed (via stats dashboard) | Item Count |
|---|---|---|---|
| all | 10 | ~1600 | 35 |
| keep_episodes | 10 | ~1600 | 30 |
| keep_seasons | 1 | ~1600 | 20 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Latest tests (via
|
| Cleanup Mode | Keep Count | Est. GB Freed (via stats dashboard) | Item Count |
|---|---|---|---|
| all | 1 | 991 | 13 |
| keep_episodes | 10 | ~1200 | 13 |
| keep_seasons | 1 | ~1100 | 5 |
sweep_until_gb_free: 14000
| Cleanup Mode | Keep Count | Est. GB Freed (via stats dashboard) | Item Count |
|---|---|---|---|
| all | 10 | 95 | 4 |
| keep_episodes | 10 | 681 | 11 |
| keep_seasons | 1 | 613 | 3 |
sweep_until_gb_free: 15500
| Cleanup Mode | Keep Count | Est. GB Freed (via stats dashboard) | Item Count |
|---|---|---|---|
| all | 10 | ~1700 | 17 |
| keep_episodes | 10 | ~1800 | 17 |
| keep_seasons | 1 | ~1900 | 11 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Closing as a better solution is in #305. |
Why
Myself and another person (see #158) are keen for this feature. Making it the ideal library management tool.
This filters control which content is eligible for deletion, but nothing previously controlled how much gets queued at once. On a large shared disk this can result in far more content being scheduled than the current disk pressure warrants. These new options let you express a target disk state and have jellysweep stop marking items once that target would be reached.
How it works
applySweepUntilLimitruns after the normal filter chain, before items are written to the database:NOTE:
jameswrc/jellysweep. All other filters and logic like 'Keep'ing an item marked for cleaning up, will grab the next lot of media to satisfy the quota on the next sweep.sweep_until_percent_usedandsweep_until_gb_freevalues have been validated by me, and is as i expect.Some other notes;
dfreports usage as used / (used + available), not used / total — because the kernel reserves some blocks for root that are never shown as usable to normal processes. This implementation uses diskUsed + diskFree (where diskFree = Bavail via gopsutil) as the denominator, so 1sweep_until_percent_used: 67` means precisely the 67% you see in df output.Testing
Test using
sweep_until_percent_usedset to 65. Should mark ~1TBmy

dfstats as of running this test43560266240 27679889324 13682691796 67% /mnt/mediaMy storage was already 67% full, so setting sweep_until_percent_used to 65. should mean 2% is deleted.
Test using
sweep_until_gb_freeset to 14061my
dfstats43560266240 27679507848 13683073272 67% /mnt/mediaCommenting out both
sweep_until_gb_freeandsweep_until_percent_usedWould be as expected as per my config.
