feat(saves): restore from a backup: every save the copies backed up, newest first, put back after a confirmation #182

Open
dyst wants to merge 3 commits from dyst/LongshotLauncher:feat/saves-restore into main
Member

Every copy of saves backs up what it replaces first, but there was no way to get a backup back short of finding the folder and copying files by hand. Now the Saves page lists those backups and restores one, after the same confirmation an import shows.

On main: #181 (the save folder as a .zip) and #180 are merged, so this branch holds only its own commits. Merge order: #182, then the Linux backups PR (issue #188, stacked on this), then #184, #185.

What changes

Restore from a backup…, a new button under the slots on the Saves page, says how many backups there are and when the newest was made (off, with "None yet: every copy makes one first", when there are none). It opens a page listing every save in the backups folder (oot-save-backups on Windows, save-backup on Linux), newest first:

  • what made it, from the backup's name: "Before an import from Lichii" / "from a .zip file" / "from a folder" (a whole save folder imported from a .zip: its backup is the save folder, and Longshot's profile in it is what is listed and restored), "The save of Lichii before an export to it, to restore into Longshot" (an export's backup is the other program's old save; a restore puts it into Longshot, and its confirm says "Restore Lichii's old save into Longshot"), "Before an import from Hookshot", "Before a backup was restored", "v3.0.0-rc.5's own save, before the versions' saves were brought together" (a gather's backup holds one save per version folder; each is its own row), "nightly's own save, before it was deleted";
  • one row a save the game would open: where a backup (or a gather's or a delete's version folder) holds several profiles, only the game's (5a3c9e1f…0001) is listed when it is there; else each is, with its profile named in the row ("(profile 01234567…)"), so no two rows look the same. Whichever is restored goes into the game's profile. A gather's shared (set aside) folder reads as the shared save.
  • when, its slots (and when the newest was saved), its size, and its folder (the folder button opens it);
  • a folder the launcher did not name is listed by its name, at its folder's time. One with no save, a copy's hidden staging folder and plain files are left out.

Restore… opens the confirm page imports use: the backup's slots, what they replace in Longshot's save, Keep Longshot's game settings, and where Longshot's own save is backed up first (restore-backup-<stamp>, which the list shows next time). Then the result page, as for an import. The backup itself is only read. It is refused while a game or emulator runs, as every copy is.

Nothing on the page deletes a backup. That stays a file manager's job: Open the backups folder is at the bottom.

The confirm page's replaced text names only the files the backup has (one with no account.sav or option.sav leaves Longshot's), and its settings tick is hidden when the backup has no option.sav. Back returns to the backups list. A whole save folder's import is undone only in part: a restore puts back one profile's save, not the rest of the folder (docs/saves.md says so).

How

  • Core/SaveBackups.cs: List(env) (each backup folder's saves via Saves.Find, one level deeper for a gather's or a delete's, with BackupKind, the other side's name, the version folder, the time from the name) and Restore (Saves.Copy into Saves.ImportTarget, command restore, so every guarantee of a copy holds: backup first, two-rename swap, nothing half-done).
  • SaveMode.Restore and SaveOp.Backup through the confirm and result pages (IntoLongshot where they asked Mode == Import); BackupsViewModel and App/Views/BackupsView.axaml.
  • tools/screenshots: saves-backups-listed, saves-backups, saves-restore (made-up backups, laid out as the copies make them).
  • docs/saves.md: Restore from a backup; README's Saves lines.

Left for the slot PR (stacked on this one): restoring one slot from a backup rather than the whole save.

Translations

25 new texts in the 12 full catalogs. They need a native speaker's check. scripts/translations.py: only the 30 texts per catalog main already lacks.

Testing

  • python -I tests/test_launcher_core.py: 1899 checks passed on main 0e28525 (new SaveBackupsChecks: no backups folder; backups made by Saves.Copy (an import, an export to a folder), Saves.BackUpForDelete and a gather's layout, plus a staging folder, an empty one, a file and an unnamed folder; the list's order, kinds, names, version folders, paths and sizes; a dry run names the backup and makes nothing; refused while the game runs; a restore puts the backup's save back whole, leaves the backup as it was, backs Longshot's save up first; a gather's version folder's save with the game settings kept; a whole save folder's import from a .zip listed and restored; a backup deleted since it was listed; since the review: a whole-folder backup with a stray profile, a version folder with two profiles and one with the game's, an export's backup restored into Longshot, a backup with no account.sav or option.sav).
  • python -I tests/test_release.py: 37 tests OK. dotnet build App -c Release: 0 warnings, 0 errors.
  • Not done: a click-through in the real window (screens drawn headless), and Linux (Windows 11 only).

Screenshots, Before / After: in the first comment.

Every copy of saves backs up what it replaces first, but there was no way to get a backup back short of finding the folder and copying files by hand. Now the Saves page lists those backups and restores one, after the same confirmation an import shows. **On main**: #181 (the save folder as a .zip) and #180 are merged, so this branch holds only its own commits. Merge order: #182, then the Linux backups PR (issue #188, stacked on this), then #184, #185. ## What changes **Restore from a backup…**, a new button under the slots on the Saves page, says how many backups there are and when the newest was made (off, with "None yet: every copy makes one first", when there are none). It opens a page listing every save in the backups folder (`oot-save-backups` on Windows, `save-backup` on Linux), newest first: - **what made it**, from the backup's name: "Before an import from Lichii" / "from a .zip file" / "from a folder" (a whole save folder imported from a .zip: its backup is the save folder, and Longshot's profile in it is what is listed and restored), "The save of Lichii before an export to it, to restore into Longshot" (an export's backup is the other program's old save; a restore puts it into Longshot, and its confirm says "Restore Lichii's old save into Longshot"), "Before an import from Hookshot", "Before a backup was restored", "v3.0.0-rc.5's own save, before the versions' saves were brought together" (a gather's backup holds one save per version folder; each is its own row), "nightly's own save, before it was deleted"; - **one row a save the game would open**: where a backup (or a gather's or a delete's version folder) holds several profiles, only the game's (`5a3c9e1f…0001`) is listed when it is there; else each is, with its profile named in the row ("(profile 01234567…)"), so no two rows look the same. Whichever is restored goes into the game's profile. A gather's `shared (set aside)` folder reads as the shared save. - when, its slots (and when the newest was saved), its size, and its folder (the folder button opens it); - a folder the launcher did not name is listed by its name, at its folder's time. One with no save, a copy's hidden staging folder and plain files are left out. **Restore…** opens the confirm page imports use: the backup's slots, what they replace in Longshot's save, *Keep Longshot's game settings*, and where Longshot's own save is backed up first (`restore-backup-<stamp>`, which the list shows next time). Then the result page, as for an import. The backup itself is only read. It is refused while a game or emulator runs, as every copy is. Nothing on the page deletes a backup. That stays a file manager's job: *Open the backups folder* is at the bottom. The confirm page's replaced text names only the files the backup has (one with no `account.sav` or `option.sav` leaves Longshot's), and its settings tick is hidden when the backup has no `option.sav`. Back returns to the backups list. A whole save folder's import is undone only in part: a restore puts back one profile's save, not the rest of the folder (docs/saves.md says so). ## How - `Core/SaveBackups.cs`: `List(env)` (each backup folder's saves via `Saves.Find`, one level deeper for a gather's or a delete's, with `BackupKind`, the other side's name, the version folder, the time from the name) and `Restore` (`Saves.Copy` into `Saves.ImportTarget`, command `restore`, so every guarantee of a copy holds: backup first, two-rename swap, nothing half-done). - `SaveMode.Restore` and `SaveOp.Backup` through the confirm and result pages (`IntoLongshot` where they asked `Mode == Import`); `BackupsViewModel` and `App/Views/BackupsView.axaml`. - `tools/screenshots`: `saves-backups-listed`, `saves-backups`, `saves-restore` (made-up backups, laid out as the copies make them). - `docs/saves.md`: *Restore from a backup*; README's Saves lines. **Left for the slot PR** (stacked on this one): restoring one slot from a backup rather than the whole save. ## Translations 25 new texts in the 12 full catalogs. **They need a native speaker's check.** `scripts/translations.py`: only the 30 texts per catalog `main` already lacks. ## Testing - `python -I tests/test_launcher_core.py`: 1899 checks passed on main 0e28525 (new `SaveBackupsChecks`: no backups folder; backups made by `Saves.Copy` (an import, an export to a folder), `Saves.BackUpForDelete` and a gather's layout, plus a staging folder, an empty one, a file and an unnamed folder; the list's order, kinds, names, version folders, paths and sizes; a dry run names the backup and makes nothing; refused while the game runs; a restore puts the backup's save back whole, leaves the backup as it was, backs Longshot's save up first; a gather's version folder's save with the game settings kept; a whole save folder's import from a .zip listed and restored; a backup deleted since it was listed; since the review: a whole-folder backup with a stray profile, a version folder with two profiles and one with the game's, an export's backup restored into Longshot, a backup with no account.sav or option.sav). - `python -I tests/test_release.py`: 37 tests OK. `dotnet build App -c Release`: 0 warnings, 0 errors. - **Not done:** a click-through in the real window (screens drawn headless), and Linux (Windows 11 only). Screenshots, Before / After: in the first comment.
feat(saves): export the saves to one .zip file, and import one back after checking it holds only saves
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
e103e43677
Export saves… and From an emulator… gain "A .zip file…". The export writes the save files of Longshot's save folder
(account.sav, option.sav, slot_NN/progress.sav and caption.sav, with their times) and a small note
(longshot-save.json) into a file the Save As dialog picks, made beside it and renamed into place. The import checks the
zip as a Hookshot save is checked (only save files, no path out of it, no link, sizes, at least one slot with a
progress.sav; a bomb stops at what comes out, whatever the zip claims), unpacks it into a temporary folder of its own,
and copies it in as an import from a folder: confirmed first, Longshot's save backed up (import-zip-<stamp>).

Core/SaveArchive.cs with tests/launcher_core/SaveArchiveChecks.cs; the Saves scenes in tools/screenshots; docs/saves.md
"As a .zip file"; the new texts in the 12 full catalogs.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
feat(saves): restore from a backup: every save the copies backed up, newest first, put back after a confirmation
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
34d9c14713
Every copy backs up what it replaces, but getting a backup back meant copying folders by hand. The Saves page gains
"Restore from a backup…" (under the slots): a page listing every save in the backups folder, newest first, with what
made it (an import, an export, Hookshot's import, the versions' saves brought together, a version deleted), when, its
slots and its size, the folder of each one a click away. Restore… opens the import's confirmation: the backup's slots,
what they replace, Keep Longshot's game settings, and Longshot's own save backed up first (restore-backup-<stamp>).
The backup itself is only read; nothing on the page deletes one.

Core/SaveBackups.cs with tests/launcher_core/SaveBackupsChecks.cs; SaveMode.Restore through the confirm and result
pages; App/Views/BackupsView.axaml; the backup scenes in tools/screenshots; docs/saves.md "Restore from a backup"; the
new texts in the 12 full catalogs. Stacked on the .zip export and import.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Screenshots from tools/screenshots (headless, Windows layout, made-up save files and backups), this PR's base #181 (e103e43) against this PR (34d9c14).

The Saves page: Restore from a backup, under the slots

With no backup yet it is off and says why.

Before After
before after

New, no before

The Saves page with backups: how many, and when the newest was made.

listed

Restore from a backup: every save the copies backed up, newest first, what made each.

backups

Restore…: the import's confirmation, Longshot's save backed up first.

restore

Screenshots from `tools/screenshots` (headless, Windows layout, made-up save files and backups), this PR's base #181 (e103e43) against this PR (34d9c14). ### The Saves page: Restore from a backup, under the slots With no backup yet it is off and says why. | Before | After | |---|---| | ![before](https://git.magicbean.dev/attachments/ad0cf91f-b6af-4cc8-a807-d83de894c0f2) | ![after](https://git.magicbean.dev/attachments/b7cd5916-2a85-424d-ab9e-991a5cde8511) | ### New, no before The Saves page with backups: how many, and when the newest was made. ![listed](https://git.magicbean.dev/attachments/b13d640a-c342-4025-b1d3-cd842d5dd255) Restore from a backup: every save the copies backed up, newest first, what made each. ![backups](https://git.magicbean.dev/attachments/ba1574ce-c771-4670-8b09-4b29ec225d6a) Restore…: the import's confirmation, Longshot's save backed up first. ![restore](https://git.magicbean.dev/attachments/634614c6-aba7-471d-90a7-7ce65a84e136)
Collaborator

Possibly related, for context:

  • issue #146 Launcher: Updating to v3.0.0-rc.5 deleted all saves without a prompt — Potential save recovery for reported update-related save loss
Possibly related, for context: - issue #146 Launcher: Updating to v3.0.0-rc.5 deleted all saves without a prompt — Potential save recovery for reported update-related save loss
dyst force-pushed feat/saves-restore from 34d9c14713
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
to bb44444ce9
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
2026-11-17 19:54:05 +00:00
Compare
Author
Member

Rebased onto #181's whole-save-folder zip (4a9f836) and force-pushed: 3039613 (this PR's change, unchanged but for the conflicts in the catalogs, README and docs) and bb44444 (a check: a whole save folder's import from a .zip is listed among the backups and restored). 1626 checks pass, 37 release tests OK, the app builds with 0 warnings. No dialog text changed, so the screenshots stand.

Rebased onto #181's whole-save-folder zip (4a9f836) and force-pushed: 3039613 (this PR's change, unchanged but for the conflicts in the catalogs, README and docs) and bb44444 (a check: a whole save folder's import from a .zip is listed among the backups and restored). 1626 checks pass, 37 release tests OK, the app builds with 0 warnings. No dialog text changed, so the screenshots stand.
dyst force-pushed feat/saves-restore from bb44444ce9
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
to 00a924e627
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 5s
2026-11-17 20:21:17 +00:00
Compare
dyst force-pushed feat/saves-restore from 00a924e627
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 5s
to bb44444ce9
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
2026-11-17 20:21:33 +00:00
Compare
dyst force-pushed feat/saves-restore from bb44444ce9
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
to 277f71ed45
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 2s
2026-11-17 20:50:22 +00:00
Compare
Author
Member

Rebased: #181 now sits on #180 (feat/home-version-picker @ 6ed6a3e) and #182 on the new #181. Merge order: #180, #181, #182. Only the language files conflicted (both PRs added texts at their end); both sides were kept and each file checked as JSON with no duplicate key. The app builds with 0 errors; the code is otherwise unchanged, so the earlier test runs stand.

Rebased: #181 now sits on #180 (feat/home-version-picker @ 6ed6a3e) and #182 on the new #181. Merge order: #180, #181, #182. Only the language files conflicted (both PRs added texts at their end); both sides were kept and each file checked as JSON with no duplicate key. The app builds with 0 errors; the code is otherwise unchanged, so the earlier test runs stand.
dyst force-pushed feat/saves-restore from 277f71ed45
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 2s
to 04f099d93f
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
2026-11-17 21:03:13 +00:00
Compare
Author
Member

Rebased onto #181 (3fe0c90) and force-pushed: dd0d0bb, 04f099d. The merge kept main's #168 settings tick for a restore ('Keep Longshot's own game settings', hidden when there is no option.sav), with one text of its own: 'Camera, text speed and other game options from the backup replace them.' (the backup's name is a description, so #168's 'from {0}' would read oddly), in the 12 catalogs. 1717 checks, 37 release tests, 0 warnings. Merge order: #180, #181, #182.

Rebased onto #181 (3fe0c90) and force-pushed: dd0d0bb, 04f099d. The merge kept main's #168 settings tick for a restore ('Keep Longshot's own game settings', hidden when there is no option.sav), with one text of its own: 'Camera, text speed and other game options from the backup replace them.' (the backup's name is a description, so #168's 'from {0}' would read oddly), in the 12 catalogs. 1717 checks, 37 release tests, 0 warnings. Merge order: #180, #181, #182.
Author
Member

The restore confirmation after the rebase onto main (tools/screenshots, headless): main's #168 settings tick, with its own wording for a restore ("…from the backup replace them"). Before: as last posted; After: 04f099d.

Before After
before after
The restore confirmation after the rebase onto main (`tools/screenshots`, headless): main's #168 settings tick, with its own wording for a restore ("…from the backup replace them"). Before: as last posted; After: 04f099d. | Before | After | |---|---| | ![before](https://git.magicbean.dev/attachments/71710690-3e15-45ab-ab3c-e5dedadc82e3) | ![after](https://git.magicbean.dev/attachments/cac7330b-e9b3-4ca2-91c7-aa462aed9ed1) |
dyst force-pushed feat/saves-restore from 04f099d93f
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
to 7c78639d14
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
2026-11-17 21:14:17 +00:00
Compare
Author
Member

Rebased onto main (8594b47: #180, #171 and #179 merged). Only the language files and the screenshot tool's scene list conflicted, both sides adding entries; both kept, each catalog checked as JSON with no duplicate key, the app and the screenshot tool build with 0 warnings. The code is otherwise unchanged, so the earlier test runs stand. Merge order: #181, #182, #184, #185.

Rebased onto main (8594b47: #180, #171 and #179 merged). Only the language files and the screenshot tool's scene list conflicted, both sides adding entries; both kept, each catalog checked as JSON with no duplicate key, the app and the screenshot tool build with 0 warnings. The code is otherwise unchanged, so the earlier test runs stand. Merge order: #181, #182, #184, #185.
HumanBean left a comment

Verdict: Request changes. The restore itself is safe: it goes through Saves.Copy, so Longshot's save is backed up first, put in place by two renames, and refused while a game runs. One thing to fix first: a backup that holds several profiles lists each of them under the same label, and any of them restores into the game's profile. The description says only Longshot's profile is listed. Merge after #181.

For a player, this adds a way to get back any save a copy replaced, an import, an export, the versions' saves brought together or a deleted version, without digging through oot-save-backups by hand. That is a real gain for the data players care most about. It changes no existing path except the shared confirm and result pages, where Mode == Import became IntoLongshot.

Reviewed: 7c78639d (pr/182) against a00d7d2d (pr/181's head, which sits on main 8594b470), so only this PR's two commits. Read in full: Core/SaveBackups.cs, the App/ViewModels/SavesViewModel.cs diff with the confirm and result view models around it, App/Views/BackupsView.axaml, the SavesView.axaml, MainWindow.axaml and Views.cs hunks, tests/launcher_core/SaveBackupsChecks.cs, the tools/screenshots diff, docs/saves.md and README. Also read, because the restore relies on them: Saves.Copy, Find, Describe, ImportTarget, Gather's backup layout, BackUpForDelete/SaveIn, SaveArchive.ImportWhole's backup name and HookshotSaves's. Translations: all 12 catalogs parsed and compared with pr/181. Each gains the same 25 keys, none is removed or changed, and the plural forms and placeholders match. The wording was skimmed, not checked by a native speaker. Nothing run (a code review).
Fixed in this review: nothing.
Checked and fine:

  • A restore backs up what is there now. Saves.Copy(..., "restore", "backup") copies Longshot's save whole to restore-backup-<stamp> before anything is replaced, and the list then shows it as "Before a backup was restored", so a restore can be undone. The confirm page's dry run names that same folder.

  • Atomic. The new save is made in the hidden staging folder beside it and swapped in by two renames, and a failure leaves the target as it was and says where the backup is. The backup itself is only read: no path in the PR writes to or deletes from BackupRoot except the new restore backup.

  • A game or an emulator running: the real run passes running: null, so Saves.Copy asks Running(Platforms.Current) and refuses with SaveRefusal.Running, and the result page then says "Close the game first". Only the dry run uses force: true. A pending NX2navi commit is checked on both sides as before.

  • What is listed:

    • left out: hidden folders (staging), plain files, folders with no slot;
    • the launcher's names (<command>-<name>-<stamp>[-n], gather-, delete-) are parsed with the invariant culture;
    • a folder with any other name is listed by its own name, at its folder's time.

    Listing a folder of the player's own is reasonable, and restoring from it still refuses links in its slot_*, account.sav and option.sav.

  • Backups that are partial or in an older layout:

    • a backup with no account.sav/option.sav keeps Longshot's own (Copy copies only the files that exist);
    • a slot with no progress.sav lists with no time;
    • a backup with no slot is not listed, and Copy would refuse it anyway;
    • a backup deleted since the list was made is refused ("not there any more"), and the confirm page's Restore stays off.
  • Fits #175 (on main): a gather's backup is gather-<stamp>/<name>/<profile>/, and the one-level-deeper fallback finds each version folder's profiles, each with its own Part.

  • Fits #176 (on main): delete-<stamp>/<folder>/<profile>/, the same way. Since nothing here changes a backup, BackUpForDelete's reuse of an identical earlier delete-* copy still holds.

  • #168's settings tick: kept for a restore, with its own "from the backup" text.

  • Paths: Path.Combine throughout, Inside compares case by OS, and the backup root is the platform's (oot-save-backups on Windows, longshot/save-backup on Linux), outside the save folder on both.

  • The import, the export and the .zip paths behave as before: every Mode == Import that became IntoLongshot is a place where a restore needs the same side, and the Saves.ImportExport call still passes Mode == SaveMode.Import.

Blocking (to change before merge)

  1. Core/SaveBackups.cs:64 and :67: every profile Saves.Find returns in a backup becomes a row, and Restore copies any of them into Saves.ImportTarget (the game's profile). A whole save folder's .zip import (import-zip-<stamp>, from #181) backs up all of save\, and so can a gather or a delete. If that folder also held a stray profile (a copy made by hand, which ImportTarget's comment says exists), the list shows two rows with the same "Before an import from a .zip file". Only the path tells them apart, and restoring the wrong one puts a profile the game never read over the player's own. It is backed up, but it is wrong. The description says "Longshot's profile in it is what is listed and restored", and the code doesn't do that. To fix: when a backup (or a version folder in it) holds several profiles, list only Saves.UserId's when it is there, else name the profile in the row, as the import's (profile …) does. Add a check with a second profile in a whole-folder backup.

Suggestions (the author may take or leave)

  • App/ViewModels/SavesViewModel.cs:684, an export's backup: "The save of Lichii, before an export to it" is Lichii's old save, and Restore puts it into Longshot, not back into Lichii. A player undoing a bad export would expect the second. The confirm page does say Longshot is the target. Saying "into Longshot" on the row or in the confirm title for this kind would avoid the surprise.
  • A whole-folder import's restore is a partial undo: it puts back one profile's slots, account.sav and option.sav, not the rest of the save folder that the whole import replaced. One line in docs/saves.md would say so.
  • SavesViewModel.cs:388 (from before this PR): "Replaced in Longshot: …, its account.sav, and its game settings" is also shown when the backup has no account.sav/option.sav, and then Longshot keeps its own. A restore makes that case likelier than an import does.
  • A gather's shared (set aside) folder reads "shared (set aside)'s own save, before…". It could share the "shared" text.
  • Back on a restore's confirm page goes to the Saves page, not the backups list it came from.
  • SaveBackups.List runs on every Saves page load, on the UI thread, and sums every backup's size. That is fine at today's counts, and backups are never deleted, so keep an eye on it.

Questions

  • On Linux, Longshot's scripts/longshot_saves.py writes its backups to $XDG_DATA_HOME/oot-save-backups, and the launcher reads $XDG_DATA_HOME/longshot/save-backup. This predates the PR, but BackupRoot's comment ("the script's and the launcher's backups in one place") only holds on Windows, so the script's backups are not listed on Linux. Is that intended?

Testing: The author ran tests/test_launcher_core.py (1717 checks with SaveBackupsChecks), test_release.py and dotnet build on Windows 11, and posted headless screenshots. CI's compile-and-test was skipped on this head, so nothing has run the build or the checks on 7c78639d except the author's runs. The checks cover the list (kinds, order, Part, staging/empty/file/unnamed), dry run, running refusal, restore whole, backup untouched, settings kept, the whole-zip backup and a deleted backup. Missing: a backup with two profiles (the blocker), an export backup's restore, a backup with no account.sav, a click-through in the real window, and a Linux run. The restore uses the same code on both platforms, so Linux doesn't hold the merge once the blocker is fixed.
Overlaps and merge order: #181 first (this branch carries its two commits), then this one, then #183 (stacked on this; restoring one slot). The author's last comment also names #184 and #185 after it. The forge shows it mergeable now: the author rebased the stack onto main 8594b470. It needs no rebase of its own beyond following #181 if that one moves.

**Verdict: Request changes.** The restore itself is safe: it goes through `Saves.Copy`, so Longshot's save is backed up first, put in place by two renames, and refused while a game runs. One thing to fix first: a backup that holds several profiles lists each of them under the same label, and any of them restores into the game's profile. The description says only Longshot's profile is listed. Merge after https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/181. For a player, this adds a way to get back any save a copy replaced, an import, an export, the versions' saves brought together or a deleted version, without digging through `oot-save-backups` by hand. That is a real gain for the data players care most about. It changes no existing path except the shared confirm and result pages, where `Mode == Import` became `IntoLongshot`. **Reviewed:** 7c78639d (`pr/182`) against a00d7d2d (`pr/181`'s head, which sits on main 8594b470), so only this PR's two commits. Read in full: `Core/SaveBackups.cs`, the `App/ViewModels/SavesViewModel.cs` diff with the confirm and result view models around it, `App/Views/BackupsView.axaml`, the `SavesView.axaml`, `MainWindow.axaml` and `Views.cs` hunks, `tests/launcher_core/SaveBackupsChecks.cs`, the `tools/screenshots` diff, `docs/saves.md` and README. Also read, because the restore relies on them: `Saves.Copy`, `Find`, `Describe`, `ImportTarget`, `Gather`'s backup layout, `BackUpForDelete`/`SaveIn`, `SaveArchive.ImportWhole`'s backup name and `HookshotSaves`'s. Translations: all 12 catalogs parsed and compared with `pr/181`. Each gains the same 25 keys, none is removed or changed, and the plural forms and placeholders match. The wording was skimmed, not checked by a native speaker. Nothing run (a code review). **Fixed in this review:** nothing. **Checked and fine:** - A restore backs up what is there now. `Saves.Copy(..., "restore", "backup")` copies Longshot's save whole to `restore-backup-<stamp>` before anything is replaced, and the list then shows it as "Before a backup was restored", so a restore can be undone. The confirm page's dry run names that same folder. - Atomic. The new save is made in the hidden staging folder beside it and swapped in by two renames, and a failure leaves the target as it was and says where the backup is. The backup itself is only read: no path in the PR writes to or deletes from `BackupRoot` except the new restore backup. - A game or an emulator running: the real run passes `running: null`, so `Saves.Copy` asks `Running(Platforms.Current)` and refuses with `SaveRefusal.Running`, and the result page then says "Close the game first". Only the dry run uses `force: true`. A pending NX2navi commit is checked on both sides as before. - What is listed: - left out: hidden folders (staging), plain files, folders with no slot; - the launcher's names (`<command>-<name>-<stamp>[-n]`, `gather-`, `delete-`) are parsed with the invariant culture; - a folder with any other name is listed by its own name, at its folder's time. Listing a folder of the player's own is reasonable, and restoring from it still refuses links in its `slot_*`, `account.sav` and `option.sav`. - Backups that are partial or in an older layout: - a backup with no `account.sav`/`option.sav` keeps Longshot's own (`Copy` copies only the files that exist); - a slot with no `progress.sav` lists with no time; - a backup with no slot is not listed, and `Copy` would refuse it anyway; - a backup deleted since the list was made is refused ("not there any more"), and the confirm page's Restore stays off. - Fits https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/175 (on main): a gather's backup is `gather-<stamp>/<name>/<profile>/`, and the one-level-deeper fallback finds each version folder's profiles, each with its own Part. - Fits https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/176 (on main): `delete-<stamp>/<folder>/<profile>/`, the same way. Since nothing here changes a backup, `BackUpForDelete`'s reuse of an identical earlier `delete-*` copy still holds. - https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/168's settings tick: kept for a restore, with its own "from the backup" text. - Paths: `Path.Combine` throughout, `Inside` compares case by OS, and the backup root is the platform's (`oot-save-backups` on Windows, `longshot/save-backup` on Linux), outside the save folder on both. - The import, the export and the .zip paths behave as before: every `Mode == Import` that became `IntoLongshot` is a place where a restore needs the same side, and the `Saves.ImportExport` call still passes `Mode == SaveMode.Import`. **Blocking** (to change before merge) 1. `Core/SaveBackups.cs:64` and `:67`: every profile `Saves.Find` returns in a backup becomes a row, and `Restore` copies any of them into `Saves.ImportTarget` (the game's profile). A whole save folder's .zip import (`import-zip-<stamp>`, from https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/181) backs up all of `save\`, and so can a gather or a delete. If that folder also held a stray profile (a copy made by hand, which `ImportTarget`'s comment says exists), the list shows two rows with the same "Before an import from a .zip file". Only the path tells them apart, and restoring the wrong one puts a profile the game never read over the player's own. It is backed up, but it is wrong. The description says "Longshot's profile in it is what is listed and restored", and the code doesn't do that. To fix: when a backup (or a version folder in it) holds several profiles, list only `Saves.UserId`'s when it is there, else name the profile in the row, as the import's `(profile …)` does. Add a check with a second profile in a whole-folder backup. **Suggestions** (the author may take or leave) - `App/ViewModels/SavesViewModel.cs:684`, an export's backup: "The save of Lichii, before an export to it" is Lichii's old save, and Restore puts it into **Longshot**, not back into Lichii. A player undoing a bad export would expect the second. The confirm page does say Longshot is the target. Saying "into Longshot" on the row or in the confirm title for this kind would avoid the surprise. - A whole-folder import's restore is a partial undo: it puts back one profile's slots, `account.sav` and `option.sav`, not the rest of the save folder that the whole import replaced. One line in docs/saves.md would say so. - `SavesViewModel.cs:388` (from before this PR): "Replaced in Longshot: …, its account.sav, and its game settings" is also shown when the backup has no `account.sav`/`option.sav`, and then Longshot keeps its own. A restore makes that case likelier than an import does. - A gather's `shared (set aside)` folder reads "shared (set aside)'s own save, before…". It could share the `"shared"` text. - Back on a restore's confirm page goes to the Saves page, not the backups list it came from. - `SaveBackups.List` runs on every Saves page load, on the UI thread, and sums every backup's size. That is fine at today's counts, and backups are never deleted, so keep an eye on it. **Questions** - On Linux, Longshot's `scripts/longshot_saves.py` writes its backups to `$XDG_DATA_HOME/oot-save-backups`, and the launcher reads `$XDG_DATA_HOME/longshot/save-backup`. This predates the PR, but `BackupRoot`'s comment ("the script's and the launcher's backups in one place") only holds on Windows, so the script's backups are not listed on Linux. Is that intended? **Testing:** The author ran `tests/test_launcher_core.py` (1717 checks with `SaveBackupsChecks`), `test_release.py` and `dotnet build` on Windows 11, and posted headless screenshots. CI's compile-and-test was **skipped** on this head, so nothing has run the build or the checks on 7c78639d except the author's runs. The checks cover the list (kinds, order, Part, staging/empty/file/unnamed), dry run, running refusal, restore whole, backup untouched, settings kept, the whole-zip backup and a deleted backup. Missing: a backup with two profiles (the blocker), an export backup's restore, a backup with no `account.sav`, a click-through in the real window, and a Linux run. The restore uses the same code on both platforms, so Linux doesn't hold the merge once the blocker is fixed. **Overlaps and merge order:** https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/181 first (this branch carries its two commits), then this one, then https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/183 (stacked on this; restoring one slot). The author's last comment also names https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/184 and https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/185 after it. The forge shows it mergeable now: the author rebased the stack onto main 8594b470. It needs no rebase of its own beyond following https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/181 if that one moves.
@ -514,0 +681,4 @@
return b.Kind switch
{
BackupKind.Import => Tr.F("Before an import from {0}", Other()),
BackupKind.Export => Tr.F("The save of {0}, before an export to it", Other()),
Owner

An export's backup is the other side's old save, but Restore puts it into Longshot, not back where it came from. Say 'into Longshot' here or in the confirm title for this kind. (Suggestion.)

An export's backup is the other side's old save, but Restore puts it into Longshot, not back where it came from. Say 'into Longshot' here or in the confirm title for this kind. (Suggestion.)
@ -514,0 +688,4 @@
{
"shared" => Tr.T("The shared save, before the versions' saves were brought together"),
null => Tr.T("Before the versions' saves were brought together"),
var p => Tr.F("{0}'s own save, before the versions' saves were brought together", p),
Owner

nit: a gather's 'shared (set aside)' folder reads "shared (set aside)'s own save, …"; it could use the 'shared' text.

nit: a gather's 'shared (set aside)' folder reads "shared (set aside)'s own save, …"; it could use the 'shared' text.
@ -0,0 +61,4 @@
var found = new List<(SaveProfile Profile, string? Part)>();
try
{
found.AddRange(Saves.Find(folder).Select(p => (p, (string?)null)));
Owner

Every profile Find returns becomes a row, and Restore puts any of them into ImportTarget. A whole save folder's backup (import-zip-*) with a stray profile lists two rows with the same label, and the wrong one goes over the player's own profile. List only Saves.UserId's when it is there, else name the profile in the row. (Blocking, see the summary.)

Every profile Find returns becomes a row, and Restore puts any of them into ImportTarget. A whole save folder's backup (import-zip-*) with a stray profile lists two rows with the same label, and the wrong one goes over the player's own profile. List only Saves.UserId's when it is there, else name the profile in the row. (Blocking, see the summary.)
@ -0,0 +64,4 @@
found.AddRange(Saves.Find(folder).Select(p => (p, (string?)null)));
if (found.Count == 0)
foreach (var sub in Directory.EnumerateDirectories(folder).Order(StringComparer.Ordinal))
found.AddRange(Saves.Find(sub).Select(p => (p, (string?)System.IO.Path.GetFileName(sub))));
Owner

The same here for a gather's or a delete's version folder with more than one profile in it.

The same here for a gather's or a delete's version folder with more than one profile in it.
dyst force-pushed feat/saves-restore from 7c78639d14
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
to a2617e645e
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
2026-11-17 22:00:49 +00:00
Compare
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/saves-restore:dyst-feat/saves-restore'
git switch 'dyst-feat/saves-restore'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!182
No description provided.