feat: add clean command to remove temp files, logs, and cached data

Adds `unarr clean` with interactive confirmation, --dry-run, --yes,
and --all flags. Safely skips recent usenet resume files (<7 days) to
preserve download progress. Includes platform-specific PID detection
(Unix signal 0 / Windows heartbeat heuristic), CleanableBytes callback
for future heartbeat reporting, and uses shared ui.FormatBytes.
This commit is contained in:
Deivid Soto 2026-03-29 11:04:51 +02:00
parent 3d6142a62e
commit 35e5298f23
9 changed files with 578 additions and 1 deletions

View file

@ -105,6 +105,7 @@ unarr start
|---------|-------------|
| `unarr stats` | Show catalog statistics |
| `unarr doctor` | Diagnose configuration and connectivity |
| `unarr clean` | Remove temporary files, logs, and cached data |
| `unarr self-update` | Update unarr to the latest version |
| `unarr version` | Show version info |
| `unarr completion <shell>` | Generate shell completion scripts |
@ -219,6 +220,19 @@ unarr self-update --force # reinstall even if up to date
`unarr doctor` checks: config file, API key, server connectivity (with latency), agent registration, download directory, disk space, and version.
## Clean
Remove temporary files, logs, resume data, and other artifacts generated by unarr. Shows what will be removed and asks for confirmation before deleting.
```bash
unarr clean # Show files and confirm before removing
unarr clean --dry-run # Show what would be removed (no prompt)
unarr clean --yes # Skip confirmation
unarr clean --all # Also remove the data directory
```
**Cleans:** log files, daemon state, stale usenet resume files (> 7 days), stream temp data, upgrade temp files, and stale atomic-write temps. Recent resume files are kept to preserve download progress for paused or interrupted downloads. Never removes your config file, downloaded media, or partial torrent/debrid downloads.
## Alias (optional)
Create a shell alias for shorter commands: