fix(home): deleting a version keeps the save in its folder: taken in or backed up first #176

Merged
HumanBean merged 2 commits from madebyjordan/LongshotLauncher:fix/delete-keeps-saves into main 2026-11-17 15:58:30 +00:00
Member

Deleting a version deleted its whole game folder, including a save in its user\save, with no copy kept. On Windows that folder holds a save when the game was started outside the launcher (Explorer, a taskbar pin, Steam), or when the start-up gather was skipped (the game was running) or failed. Now Delete never loses a save and never leaves the player stuck.

What changes

  • BuildRegistry.DeleteGame, which the Delete dialog calls:

    1. runs DeleteFolder's refusal checks first (not a game folder, a link, the home, a kept folder, a folder holding the shared saves), so a folder it will refuse is never touched;
    2. on Windows, gathers that folder alone, so its save joins the shared one;
    3. copies whatever is still in user\save whole to <backups>\delete-<stamp>\<folder>, checked byte for byte (a retry with nothing changed reuses an identical earlier copy);
    4. deletes the folder. The folder stays only when that copy can't be made, and the notice names it.

    Linux is never stuck either: its save is backed up, then the folder goes.

  • DeleteFolder backs up the same way for the old-folders offer. With no backup place given it still refuses a folder that holds a save.

  • A delete that stops part-way (a file held open, a read-only file) still reports where the backup is (FolderNotDeleted), in the dialog and in the old-folders offer.

  • Gathers take a cross-process lock (Saves.GatherAlone): an exclusive lock file, .longshot-gather.lock, in Longshot's user folder. Start-up, Play, the desktop shortcut's --play and Delete all go through it. A gather waits up to 10 s, then is refused with nothing changed.

  • On the screen: the row shows as deleting before the gather starts; a gather or backup notice is kept if the delete then fails; the reason a backup failed is a catalog text in all 12 catalogs plus es-419.

Testing

Windows 11, .NET SDK 10.0.404; TEMP on its long path.

  • python -I tests/test_launcher_core.py: the check commit c61a25f fails on main: Deleting a version's folder deleted the save in its user\save, with no copy kept. With the fix, 1461 checks passed. Merged with the gather PR, 1484.
  • Checks cover: backup fails, gather skipped, gather works, the shared save newer, gather fails, rename refused, a retry reusing the copy (one byte changed at the same length), Linux, no save, a folder holding the shared saves, an unreadable save (a Windows deny rule; skipped as root), a linked save, a delete stopping part-way, a refused folder whose save stays untouched, a gather while the lock is held.
  • Mutations tried, all caught: removing the gather in DeleteGame, skipping the backup, comparing lengths only, removing the refusal checks, gathering without the lock, dropping the backup path on a failed delete.
  • Reviewed cold by three separate agents in turn; every blocking point they found is fixed here.

Not tested: the dialog in a real window, and a file the real game holds open (a fault hook stands in).

Known, not changed here:

  • Play and start-up gather on the window's thread, so they can wait up to 10 s if a delete is gathering at that moment. A follow-up could move the gather off that thread.
  • The lock file creates %APPDATA%\Longshot at every Windows start.
  • LauncherService.Remove(deleteFiles: true) has no caller; it could go.

🤖 Generated with Claude Code

Deleting a version deleted its whole game folder, including a save in its `user\save`, with no copy kept. On Windows that folder holds a save when the game was started outside the launcher (Explorer, a taskbar pin, Steam), or when the start-up gather was skipped (the game was running) or failed. Now Delete never loses a save and never leaves the player stuck. ## What changes - **`BuildRegistry.DeleteGame`**, which the Delete dialog calls: 1. runs `DeleteFolder`'s refusal checks first (not a game folder, a link, the home, a kept folder, a folder holding the shared saves), so a folder it will refuse is never touched; 2. on Windows, gathers that folder alone, so its save joins the shared one; 3. copies whatever is still in `user\save` whole to `<backups>\delete-<stamp>\<folder>`, checked byte for byte (a retry with nothing changed reuses an identical earlier copy); 4. deletes the folder. The folder stays only when that copy can't be made, and the notice names it. Linux is never stuck either: its save is backed up, then the folder goes. - **`DeleteFolder`** backs up the same way for the old-folders offer. With no backup place given it still refuses a folder that holds a save. - **A delete that stops part-way** (a file held open, a read-only file) still reports where the backup is (`FolderNotDeleted`), in the dialog and in the old-folders offer. - **Gathers take a cross-process lock** (`Saves.GatherAlone`): an exclusive lock file, `.longshot-gather.lock`, in Longshot's user folder. Start-up, Play, the desktop shortcut's `--play` and Delete all go through it. A gather waits up to 10 s, then is refused with nothing changed. - **On the screen**: the row shows as deleting before the gather starts; a gather or backup notice is kept if the delete then fails; the reason a backup failed is a catalog text in all 12 catalogs plus es-419. ## Testing Windows 11, .NET SDK 10.0.404; TEMP on its long path. - `python -I tests/test_launcher_core.py`: the check commit `c61a25f` fails on main: `Deleting a version's folder deleted the save in its user\save, with no copy kept.` With the fix, 1461 checks passed. Merged with the gather PR, 1484. - Checks cover: backup fails, gather skipped, gather works, the shared save newer, gather fails, rename refused, a retry reusing the copy (one byte changed at the same length), Linux, no save, a folder holding the shared saves, an unreadable save (a Windows deny rule; skipped as root), a linked save, a delete stopping part-way, a refused folder whose save stays untouched, a gather while the lock is held. - Mutations tried, all caught: removing the gather in `DeleteGame`, skipping the backup, comparing lengths only, removing the refusal checks, gathering without the lock, dropping the backup path on a failed delete. - Reviewed cold by three separate agents in turn; every blocking point they found is fixed here. Not tested: the dialog in a real window, and a file the real game holds open (a fault hook stands in). Known, not changed here: - Play and start-up gather on the window's thread, so they can wait up to 10 s if a delete is gathering at that moment. A follow-up could move the gather off that thread. - The lock file creates `%APPDATA%\Longshot` at every Windows start. - `LauncherService.Remove(deleteFiles: true)` has no caller; it could go. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On Windows a build started outside the launcher (Explorer, the taskbar,
Steam) keeps its save in its own <folder>\user\save, and Saves.Gather
may not have taken it in yet (skipped while Longshot ran at the
launcher's start, or failed). Deleting that version then deleted the
save with the folder, with no backup. This check makes such a folder
and deletes it as the home's Delete does; it fails on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(home): deleting a version keeps the save in its folder: taken in or backed up first
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
72a09ee206
A Windows build started outside the launcher (Explorer, the taskbar,
Steam) saves in its own <folder>\user\save, and the gather at the
launcher's start may have been skipped (Longshot ran) or failed. Delete
only refused while Longshot ran, then deleted the whole folder, that
save with it, with no backup.

Now the home's Delete goes through BuildRegistry.DeleteGame. A folder
DeleteFolder refuses (a link, one holding another build, the home or
the shared saves) is refused first, its save untouched. Then on Windows
the folder's own save is brought into the shared one (Saves.Gather on
that folder alone, backed up, renamed aside). Whatever is still in
user\save (the gather failed or could not rename it, or Linux, where
nothing is gathered) is copied whole to the backups,
delete-<stamp>\<folder name>, and the copy checked byte for byte before
the folder goes (Saves.BackUpForDelete; an identical earlier copy is
used again on a retry). Only when no checked copy can be made does the
folder stay, and the home says why, naming the folder; a delete that
stops half-way (a file in use) still names the copy (FolderNotDeleted).
The player is never left with a folder that cannot be deleted, and no
save is lost.

BuildRegistry.DeleteFolder does the same backup for its other callers
(an old version's folder from the home's offer, Remove), and still
refuses a save when given nowhere to back it up. Gathers now run one at
a time across launcher processes (Saves.GatherAlone: an exclusive lock
file in Longshot's user folder, waited for 10 s, then refused with
nothing changed), as a desktop shortcut's --play gathers in a process
of its own. The row is marked deleting before the gather, and a notice
about the gather or the backup is kept when the delete then fails. A
user\save that cannot be read counts as a save. Saves.Fault gains
"rename" and "backup" for the checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator

Possibly related, for context:

  • PR #175 fix(saves): bringing the builds' saves together merges them slot by slot, never over a kept slot — Overlapping gather lock and save-handling changes; says tested with this delete PR
  • issue #146 Launcher: Updating to v3.0.0-rc.5 deleted all saves without a prompt — Open report of saves lost during update; related save-protection issue
Possibly related, for context: - PR #175 fix(saves): bringing the builds' saves together merges them slot by slot, never over a kept slot — Overlapping gather lock and save-handling changes; says tested with this delete PR - issue #146 Launcher: Updating to v3.0.0-rc.5 deleted all saves without a prompt — Open report of saves lost during update; related save-protection issue
HumanBean deleted branch fix/delete-keeps-saves 2026-11-17 15:58:31 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/LongshotLauncher!176
No description provided.