Skip to content

fix(wpm): bound the rollback copies and let wpm clean reclaim them - #1210

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/backup-retention
Oct 17, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/backup-retention

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes the retention half of #1208; the live verification of the automatic prune follows the next release (the prune runs inside the self-update helper, which is the downloaded binary — see the second commit of #1209 for why that path is now logged).

Why

Every wpm update winuxcmd writes backup/winuxcmd-before-update-<pid>.exe, and nothing ever pruned them. On the machine where this was measured .wpm\backup held 61.8 MB of rollback copies — every image that machine had ever run — and no command surfaced or reclaimed it (wpm clean covered cache and staging only). Related and the same shape: the niubash install directory carries five niu.exe.* copies (54.5 MB).

What changes

  • prune_update_backups(root, 2) runs before each update writes its own copy. Ordered by write time (the file names carry a pid, not a timestamp, so sorting by name would be wrong), the newest two survive. Best effort: an image another process holds is left rather than failing the update.
  • wpm clean backup removes them on demand, and wpm clean all now includes them — that is the command a user types when reclaiming space.
  • The user guide documents both and says how many copies an update keeps.

Verification

wpm.clean_backup_removes_rollback_copies: clean backup removes the copies and leaves .wpm/indexes untouched; after a new copy appears, clean all takes the directory as well. wpm.* 61/61.

Not here

Every self-update writes `backup/winuxcmd-before-update-<pid>.exe` and nothing
ever pruned them, so a machine that has taken a handful of updates carries every
image it has ever run - 61.8 MB of rollback copies on the machine where this was
measured, growing silently and never surfaced by any command
(#1208).

- `prune_update_backups(root, 2)` runs before each update writes its own copy,
  ordered by write time (the names carry a pid, not a timestamp), so the newest
  two rollback images survive and older ones go. Best effort: an image another
  process holds stays rather than failing the update.
- `wpm clean backup` removes them on demand and `wpm clean all` now includes
  them - that is the command a user types when reclaiming space.
- The guide documents both, and says how many the update keeps.

Test: `wpm.clean_backup_removes_rollback_copies` (the target removes the copies
and leaves the index alone; `clean all` takes the directory too). `wpm.*` 61/61.
@caomengxuan666
caomengxuan666 merged commit adb51d0 into main Oct 17, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/backup-retention branch October 17, 2026 07:16
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.

1 participant