feat(saves): export Longshot's save folder to one .zip, whole, and import one back #181

Merged
HumanBean merged 2 commits from dyst/LongshotLauncher:feat/saves-zip into main 2026-11-17 21:16:28 +00:00
Member

Players had no way to keep their saves as one file, or to send them to another PC: Export copied them into a folder, and a backup meant copying the save folder by hand. Now Export saves… zips Longshot's whole save folder into one .zip, and From an emulator… imports one back.

What changes

Export saves… > A .zip file… (new option in the picker, after Another folder…): the system's Save As picks where, starting from Longshot saves <date>.zip. The confirm page says it is a new file (or one written over), what is in it, and that nothing in the saves changes.

What the zip holds: Longshot's save folder, whole, as it is on the disk.

  • save/ is the zip's top folder: save/<user id>/account.sav, option.sav, every slot_NN/ with whatever it holds, any other file or folder there (nested and empty ones too), and every other profile folder beside Longshot's. No filtering of which files go in. Each file keeps its time, so every slot still says when it was saved.
  • Nothing from beside the save folder in Longshot's user folder: not longshot_options.ini, mouse_sens.txt or present.txt. The settings are separate.
  • Links and junctions in the save folder are left out, never followed; the result page names them ("Left out, being links: …").
  • Nothing added among the files: what made the zip (the launcher's version), when, and its slots are the zip's comment, which any zip tool shows.

It is written beside where it goes and renamed into place, so a failure leaves the file that was there. Refused while Longshot, Hookshot or an emulator runs, into the save folder itself, and for a folder above the caps below (so every zip it writes can be imported again).

From an emulator… > A .zip file… imports one. Which rule applies depends on what the zip holds:

  • A whole save folder (what Export writes: every entry under save/, and save/5a3c9e1f0b7d24680000000000000001/, the profile the game opens, holding a slot with a progress.sav): taken as it is, any file, folder or profile in it, checked for safety only: no name leading out of the zip (.., /, a drive, backslashes included), no link entry, no file in it twice, the caps. It takes the place of Longshot's whole save folder: the confirm page says so ("Replaced: Longshot's whole save folder (3 slots, saved …) and every file in it"), Longshot's is backed up whole first (import-zip-<stamp>), the new one is made beside it and swapped in by two renames, so a failure leaves it as it was. Keep Longshot's game settings keeps each profile's option.sav.
  • Anything else, through the same button: a zip made by hand of a save folder or of the folder above it, Hookshot's or an emulator's save folder zipped (another profile id than Longshot's), a slot's zip (#183), or this PR's first zips. These keep the save-files rule, as a Hookshot save is checked (HookshotSaves.Validate): only account.sav, option.sav, slot_NN/progress.sav, slot_NN/caption.sav (the folders they sit in skipped; a file manager's leftovers __MACOSX, .DS_Store, Thumbs.db, desktop.ini left out); no empty file, none above 4 MB; at least one slot with a progress.sav; the same safety checks. Copied into Longshot's profile as an import from a folder is (Saves.Copy): its slots, account.sav and (unless kept) option.sav replaced, its other files left; backup import-zip-<stamp>.

The caps (raised for a whole folder, which may hold several profiles and files nobody knows): the zip at most 512 MB; at most 512 MB unpacked in all and 10,000 entries; one file of a whole folder at most 64 MB (save files alone: 4 MB, as before). A save folder is a few hundred kilobytes for each profile, so only a bomb or a folder holding something else entirely meets them. What comes out is counted while it is unpacked, whatever sizes the zip claims.

Either way the zip is unpacked into a folder of its own in the system's temporary folder (never a save folder, never the backups), checked there, and deleted when the import is done or left; one an import never finished (the launcher closed in between) goes at the next import, a day later.

The Saves page's two buttons mention the .zip: Choose an emulator, a save folder or a .zip, Send to an emulator, a folder or a .zip.

How

  • Core/SaveArchive.cs: ExportSave (the save folder whole), ExportSlot (one slot's folder whole, used by #183), Read (slots, rule and problems without unpacking), Unpack (an IDisposable temporary folder, Whole or save files), ImportWhole (backup, beside, two renames). Saves.Zip names the save-files import's side, so its backup is import-zip-<stamp> too. Saves.CopyTree, DeleteTree, Beside and RefuseLinks are now internal.
  • IWindowHost.PickSaveFileAsync: the system's Save As (overwrite prompt on).
  • SavesViewModel: the picker's new option; SaveOp.Zip/Unpacked; the confirm page's zip side and texts, WholeImport, ToReplaced/ShowKeep; the result page names left-out links.
  • tools/screenshots: a saves scene (the Saves page, from made-up save files), the two pickers, and the zip export, import and refusal.
  • docs/saves.md: As a .zip file; README's Saves lines.

Translations

Every new text is written in the 12 full catalogs (de, es, fr, it, ja, ko, nl, pl, pt-BR, ru, zh-Hans, zh-Hant). They need a native speaker's check. scripts/translations.py: the same 30 texts per catalog main already lacks, nothing more, nothing left over.

Testing

  • python -I tests/test_launcher_core.py: 1613 checks passed. New SaveArchiveChecks:
    • a save folder with a nested folder, an empty one, a file nobody knows, a binary file and another profile, exported and imported back byte for byte; the settings beside it stay out;
    • links (a file and a folder pointing outside) left out and named, what they point to never in the zip;
    • the comment; refused while running, into the save folder, without a save, above the file cap; a failed write keeps the old zip;
    • the whole-folder import: dry run, refused while running, a failed swap leaves the folder, then in place whole with the old one backed up, keep settings;
    • whole folders refused only for safety (save/../, a link, a file twice, no save in Longshot's profile, above the caps) and accepted with unknown and empty files;
    • the other layouts: made by hand, Hookshot's profile id (save files only, an unknown file refuses it), the first zips; and the hostile ones (../, slot_00/../../, /abs, C:/, backslashes, a file that is no save's, two places, empty, twice, no slot, no progress.sav, a Unix symlink entry, a 4 MB+1 bomb, a file that is no zip), nothing written outside its folder.
  • python -I tests/test_release.py: 37 tests OK. dotnet build App -c Release and tools/screenshots: 0 warnings, 0 errors.
  • Not done: a click-through in the real window (the screens are drawn headless), and Linux (Windows 11 only). The Save As and Open dialogs are the system's, untested here.

Screenshots, Before / After: the first comment; the screens whose text changed with the whole folder, in a later comment.

  • Issue #68 proposed a .longshot-save zip with a manifest; this is the plain-.zip form of it, readable by any unzip tool.
  • #166 (export to an empty folder) and #168 (the settings tick's wording) touch the same confirm page; whichever merges second rebases.
  • Stacked on this one: #182 (restore from a backup), then #183 (one slot at a time, WIP). Merge order: #181, #182, #184, #185 (#180 is merged).
Players had no way to keep their saves as one file, or to send them to another PC: Export copied them into a folder, and a backup meant copying the save folder by hand. Now Export saves… zips Longshot's whole save folder into one .zip, and From an emulator… imports one back. ## What changes **Export saves… > A .zip file…** (new option in the picker, after *Another folder…*): the system's Save As picks where, starting from `Longshot saves <date>.zip`. The confirm page says it is a new file (or one written over), what is in it, and that nothing in the saves changes. **What the zip holds: Longshot's `save` folder, whole, as it is on the disk.** - `save/` is the zip's top folder: `save/<user id>/account.sav`, `option.sav`, every `slot_NN/` with whatever it holds, any other file or folder there (nested and empty ones too), and every other profile folder beside Longshot's. No filtering of which files go in. Each file keeps its time, so every slot still says when it was saved. - **Nothing from beside the save folder** in Longshot's user folder: not `longshot_options.ini`, `mouse_sens.txt` or `present.txt`. The settings are separate. - **Links and junctions** in the save folder are left out, never followed; the result page names them ("Left out, being links: …"). - **Nothing added among the files:** what made the zip (the launcher's version), when, and its slots are the zip's comment, which any zip tool shows. It is written beside where it goes and renamed into place, so a failure leaves the file that was there. Refused while Longshot, Hookshot or an emulator runs, into the save folder itself, and for a folder above the caps below (so every zip it writes can be imported again). **From an emulator… > A .zip file…** imports one. **Which rule applies depends on what the zip holds:** - **A whole save folder** (what Export writes: every entry under `save/`, and `save/5a3c9e1f0b7d24680000000000000001/`, the profile the game opens, holding a slot with a `progress.sav`): taken **as it is**, any file, folder or profile in it, checked **for safety only**: no name leading out of the zip (`..`, `/`, a drive, backslashes included), no link entry, no file in it twice, the caps. It takes the place of **Longshot's whole save folder**: the confirm page says so ("Replaced: Longshot's whole save folder (3 slots, saved …) and every file in it"), Longshot's is backed up whole first (`import-zip-<stamp>`), the new one is made beside it and swapped in by two renames, so a failure leaves it as it was. *Keep Longshot's game settings* keeps each profile's `option.sav`. - **Anything else**, through the same button: a zip made by hand of a save folder or of the folder above it, **Hookshot's or an emulator's** save folder zipped (another profile id than Longshot's), a slot's zip (#183), or this PR's first zips. These keep the **save-files rule**, as a Hookshot save is checked (`HookshotSaves.Validate`): only `account.sav`, `option.sav`, `slot_NN/progress.sav`, `slot_NN/caption.sav` (the folders they sit in skipped; a file manager's leftovers `__MACOSX`, `.DS_Store`, `Thumbs.db`, `desktop.ini` left out); no empty file, none above 4 MB; at least one slot with a `progress.sav`; the same safety checks. Copied into Longshot's profile as an import from a folder is (`Saves.Copy`): its slots, `account.sav` and (unless kept) `option.sav` replaced, its other files left; backup `import-zip-<stamp>`. **The caps** (raised for a whole folder, which may hold several profiles and files nobody knows): the zip at most **512 MB**; at most **512 MB** unpacked in all and **10,000** entries; one file of a whole folder at most **64 MB** (save files alone: 4 MB, as before). A save folder is a few hundred kilobytes for each profile, so only a bomb or a folder holding something else entirely meets them. What comes out is counted while it is unpacked, whatever sizes the zip claims. Either way the zip is unpacked into a folder of its own in the system's temporary folder (never a save folder, never the backups), checked there, and deleted when the import is done or left; one an import never finished (the launcher closed in between) goes at the next import, a day later. The Saves page's two buttons mention the .zip: *Choose an emulator, a save folder or a .zip*, *Send to an emulator, a folder or a .zip*. ## How - `Core/SaveArchive.cs`: `ExportSave` (the save folder whole), `ExportSlot` (one slot's folder whole, used by #183), `Read` (slots, rule and problems without unpacking), `Unpack` (an `IDisposable` temporary folder, `Whole` or save files), `ImportWhole` (backup, beside, two renames). `Saves.Zip` names the save-files import's side, so its backup is `import-zip-<stamp>` too. `Saves.CopyTree`, `DeleteTree`, `Beside` and `RefuseLinks` are now `internal`. - `IWindowHost.PickSaveFileAsync`: the system's Save As (overwrite prompt on). - `SavesViewModel`: the picker's new option; `SaveOp.Zip`/`Unpacked`; the confirm page's zip side and texts, `WholeImport`, `ToReplaced`/`ShowKeep`; the result page names left-out links. - `tools/screenshots`: a `saves` scene (the Saves page, from made-up save files), the two pickers, and the zip export, import and refusal. - `docs/saves.md`: *As a .zip file*; README's Saves lines. ## Translations Every new text is written in the 12 full catalogs (de, es, fr, it, ja, ko, nl, pl, pt-BR, ru, zh-Hans, zh-Hant). **They need a native speaker's check.** `scripts/translations.py`: the same 30 texts per catalog `main` already lacks, nothing more, nothing left over. ## Testing - `python -I tests/test_launcher_core.py`: 1613 checks passed. New `SaveArchiveChecks`: - a save folder with a nested folder, an empty one, a file nobody knows, a binary file and another profile, exported and imported back **byte for byte**; the settings beside it stay out; - links (a file and a folder pointing outside) left out and named, what they point to never in the zip; - the comment; refused while running, into the save folder, without a save, above the file cap; a failed write keeps the old zip; - the whole-folder import: dry run, refused while running, a failed swap leaves the folder, then in place whole with the old one backed up, *keep settings*; - whole folders refused only for safety (`save/../`, a link, a file twice, no save in Longshot's profile, above the caps) and accepted with unknown and empty files; - the other layouts: made by hand, Hookshot's profile id (save files only, an unknown file refuses it), the first zips; and the hostile ones (`../`, `slot_00/../../`, `/abs`, `C:/`, backslashes, a file that is no save's, two places, empty, twice, no slot, no `progress.sav`, a Unix symlink entry, a 4 MB+1 bomb, a file that is no zip), nothing written outside its folder. - `python -I tests/test_release.py`: 37 tests OK. `dotnet build App -c Release` and `tools/screenshots`: 0 warnings, 0 errors. - **Not done:** a click-through in the real window (the screens are drawn headless), and Linux (Windows 11 only). The Save As and Open dialogs are the system's, untested here. Screenshots, Before / After: the first comment; the screens whose text changed with the whole folder, in a later comment. ## Related - Issue #68 proposed a `.longshot-save` zip with a manifest; this is the plain-`.zip` form of it, readable by any unzip tool. - #166 (export to an empty folder) and #168 (the settings tick's wording) touch the same confirm page; whichever merges second rebases. - Stacked on this one: #182 (restore from a backup), then #183 (one slot at a time, WIP). Merge order: #181, #182, #184, #185 (#180 is merged).
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]>
Author
Member

Screenshots from tools/screenshots (headless, Windows layout, made-up save files), main 321a9e1 against this PR e103e43.

The Saves page

Before After
before after

Export saves…: the picker

Before After
before after

From an emulator…: the picker

Before After
before after

New, no before

Export to a new .zip: nothing in the saves changes.

zip export

Import from a .zip: its slots, what they replace, the backup first.

zip import

A .zip that is not only saves: refused, with the reason, and Import off.

zip refused

Screenshots from `tools/screenshots` (headless, Windows layout, made-up save files), `main` 321a9e1 against this PR e103e43. ### The Saves page | Before | After | |---|---| | ![before](https://git.magicbean.dev/attachments/da1b5d86-cc40-48a1-a3d5-8d9fa0ec3333) | ![after](https://git.magicbean.dev/attachments/e0d76d69-c249-41f8-bcf4-af126f47eb3d) | ### Export saves…: the picker | Before | After | |---|---| | ![before](https://git.magicbean.dev/attachments/c5e3748e-3c8b-42e7-b32b-81bbc2a49d28) | ![after](https://git.magicbean.dev/attachments/dbe73fcd-c2fa-4b90-ba2a-b8501c888208) | ### From an emulator…: the picker | Before | After | |---|---| | ![before](https://git.magicbean.dev/attachments/138f933e-8cd0-4e74-bb30-f11b2c87794d) | ![after](https://git.magicbean.dev/attachments/041d29fa-5bb8-4e60-a9ff-e2940668ed78) | ### New, no before Export to a new .zip: nothing in the saves changes. ![zip export](https://git.magicbean.dev/attachments/b1adbe20-9ec9-444a-aac8-fb1eeef9154a) Import from a .zip: its slots, what they replace, the backup first. ![zip import](https://git.magicbean.dev/attachments/6dfc68b6-2cb9-4c68-bbac-59a2b8bf3f93) A .zip that is not only saves: refused, with the reason, and Import off. ![zip refused](https://git.magicbean.dev/attachments/1c3c3401-d107-4c75-9471-2f8b8ccc37d3)
Author
Member

Two more Saves PRs stack on this one: #182 (restore from a backup) and #183 (one slot at a time: export, copy to another slot, delete, restore one slot). Merge in that order.

Two more Saves PRs stack on this one: #182 (restore from a backup) and #183 (one slot at a time: export, copy to another slot, delete, restore one slot). Merge in that order.
feat(saves): the .zip holds Longshot's whole save folder, as it is, and imports back whole
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
4a9f836958
The zip is now the save folder itself: save/ as its top folder and everything in it, every profile, slot, file and folder
(nested and empty ones too), with their times. Nothing from beside it in the user folder (longshot_options.ini,
mouse_sens.txt, present.txt: the settings are separate); links and junctions are left out, never followed, and the result
page names them. The note is the zip's comment instead of a file among the saves.

Importing such a zip (every entry under save/, Longshot's profile holding a save) takes it as it is, checked for safety only
(no path out of it, no link, no file twice, the caps), and puts it in place of Longshot's whole save folder: backed up whole
first (import-zip-<stamp>), made beside it, two renames. Any other zip (by hand, Hookshot's, an emulator's, a slot's, the
launcher's first ones) keeps the save-files-only rule. Caps raised for a whole folder: 512 MB zip and unpacked, 10,000
entries, 64 MB a file; the export refuses a folder above them, so every zip it writes imports again.

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

The .zip is now Longshot's whole save folder, as it is (4a9f836): save/ on top, every profile, slot, file and folder in it, nested and empty ones too; nothing from beside it (longshot_options.ini, mouse_sens.txt, present.txt: the settings are separate); links left out and named; the note moved to the zip's comment. Importing such a zip puts it in place of the whole save folder (backed up first, two-rename swap), checked for safety only; any other zip (by hand, Hookshot's, an emulator's, a slot's) keeps the save-files rule. Caps raised to 512 MB zip and unpacked, 10,000 entries, 64 MB a file. New checks: a nested folder, an empty one, an unknown file and another profile round-trip byte for byte; links skipped. 1613 checks pass. The description is updated; new screenshots of the screens whose text changed follow.

The .zip is now Longshot's whole save folder, as it is (4a9f836): save/ on top, every profile, slot, file and folder in it, nested and empty ones too; nothing from beside it (longshot_options.ini, mouse_sens.txt, present.txt: the settings are separate); links left out and named; the note moved to the zip's comment. Importing such a zip puts it in place of the whole save folder (backed up first, two-rename swap), checked for safety only; any other zip (by hand, Hookshot's, an emulator's, a slot's) keeps the save-files rule. Caps raised to 512 MB zip and unpacked, 10,000 entries, 64 MB a file. New checks: a nested folder, an empty one, an unknown file and another profile round-trip byte for byte; links skipped. 1613 checks pass. The description is updated; new screenshots of the screens whose text changed follow.
Author
Member

The screens whose text changed with the whole save folder, from tools/screenshots (headless): this PR's first commit (e103e43) against now (4a9f836).

Export saves…: the picker

Before (e103e43) After (4a9f836)
before after

Export to a .zip: what is in it

Before (e103e43) After (4a9f836)
before after

Import a whole save folder: it replaces the whole folder

Before (e103e43) After (4a9f836)
before after

The refusal screen is unchanged (a zip with setup.exe among save files keeps the save-files rule).

The screens whose text changed with the whole save folder, from `tools/screenshots` (headless): this PR's first commit (e103e43) against now (4a9f836). ### Export saves…: the picker | Before (e103e43) | After (4a9f836) | |---|---| | ![before](https://git.magicbean.dev/attachments/c49d3685-f9e7-4851-87ba-6066b0e53d56) | ![after](https://git.magicbean.dev/attachments/77dacdcc-d0b6-4edf-8d84-a45a21673654) | ### Export to a .zip: what is in it | Before (e103e43) | After (4a9f836) | |---|---| | ![before](https://git.magicbean.dev/attachments/4b99c92c-ea2f-46fe-ac3b-0d3572044d07) | ![after](https://git.magicbean.dev/attachments/d57527e9-771f-4d80-9778-d59e08668a01) | ### Import a whole save folder: it replaces the whole folder | Before (e103e43) | After (4a9f836) | |---|---| | ![before](https://git.magicbean.dev/attachments/81f0a304-3bde-4d3f-9962-04f186d5c45a) | ![after](https://git.magicbean.dev/attachments/16b30899-e301-4e99-bb2c-b1b4931a170d) | The refusal screen is unchanged (a zip with `setup.exe` among save files keeps the save-files rule).
dyst changed title from feat(saves): export the saves to one .zip file, and import one back after checking it holds only saves to feat(saves): export Longshot's save folder to one .zip, whole, and import one back 2026-11-17 19:58:26 +00:00
feat(saves): importing a .zip is exclusive to saves: the game's settings stay as they are
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
5e195fdb2c
An import from a .zip never replaces option.sav. A whole save folder takes the place of Longshot's but for each profile's
option.sav, which stays byte for byte (a profile only Longshot's folder has keeps its own too); save files alone go through
SaveArchive.ImportFiles, which always keeps it. Where there is none (a fresh install), none is made: the game makes it
when it first loads a slot. The confirm page drops the "Keep Longshot's game settings" tick for a .zip and says the
settings stay; the result page says so too. Export is unchanged: the zip still holds the whole save folder.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
dyst force-pushed feat/saves-zip from 5e195fdb2c
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
to 4a9f836958
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:32 +00:00
Compare
dyst force-pushed feat/saves-zip from 4a9f836958
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
to 422a0166e9
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 20:50:19 +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-zip from 422a0166e9
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
to 3fe0c907b9
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:09 +00:00
Compare
Author
Member

Rebased onto #180 (eca781b), itself rebased onto main 7a4a61e, and force-pushed: c78d936, 3fe0c90. The merge combined main's #166 and #168 with this PR: an export to a folder with no save still makes the save there (Saves.ExportTarget), and #168's tick wording ('Keep Longshot's own game settings', what each choice does) and its hiding when there is no option.sav now hold for the .zip import too; the tick also stays hidden for a .zip export. docs/saves.md says both the empty folder and the .zip in one sentence; the screenshot tool keeps main's scenes and this PR's. 1704 checks, 37 release tests, 0 warnings. Merge order: #180, #181, #182.

Rebased onto #180 (eca781b), itself rebased onto main 7a4a61e, and force-pushed: c78d936, 3fe0c90. The merge combined main's #166 and #168 with this PR: an export to a folder with no save still makes the save there (Saves.ExportTarget), and #168's tick wording ('Keep Longshot's own game settings', what each choice does) and its hiding when there is no option.sav now hold for the .zip import too; the tick also stays hidden for a .zip export. docs/saves.md says both the empty folder and the .zip in one sentence; the screenshot tool keeps main's scenes and this PR's. 1704 checks, 37 release tests, 0 warnings. Merge order: #180, #181, #182.
Author
Member

The screens the rebase onto main changed (tools/screenshots, headless): main's #168 now words the settings tick on a .zip import too ("Keep Longshot's own game settings", what each choice does), and hides it when Longshot's save has no option.sav. Before: as last posted (4a9f836); After: 3fe0c90 on main 7a4a61e + #180.

Import from a .zip

Before After
before after

A .zip refused

Before After
before after

The zip export's confirmation is unchanged (no tick there: a .zip written replaces no settings).

The screens the rebase onto main changed (`tools/screenshots`, headless): main's #168 now words the settings tick on a .zip import too ("Keep Longshot's own game settings", what each choice does), and hides it when Longshot's save has no option.sav. Before: as last posted (4a9f836); After: 3fe0c90 on main 7a4a61e + #180. ### Import from a .zip | Before | After | |---|---| | ![before](https://git.magicbean.dev/attachments/7c9eceb2-6ae3-437d-9a55-c98dabea8993) | ![after](https://git.magicbean.dev/attachments/f97a4b48-557e-4771-9119-84480d9a243b) | ### A .zip refused | Before | After | |---|---| | ![before](https://git.magicbean.dev/attachments/91542f3c-4918-4f47-9a82-1c012ed7dbb7) | ![after](https://git.magicbean.dev/attachments/3b0e29a0-8f55-4cd7-a46b-3ff0d8d8a24c) | The zip export's confirmation is unchanged (no tick there: a .zip written replaces no settings).
dyst force-pushed feat/saves-zip from 3fe0c907b9
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
to a00d7d2def
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 21:14:15 +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 deleted branch feat/saves-zip 2026-11-17 21:16:28 +00:00
Owner

Verdict: Request changes (posted after the merge). This PR merged as 0e96947 (the same tree as a00d7d2d) while I was reviewing it, so the forge won't take a review any more, and this comes as a comment instead. The three blocking points below are now on main, and a follow-up fix should land before the next stable. The zip itself is built safely (zip-slip, links, bombs, duplicates and case clashes are all handled), but the whole-folder import and the export skip three save-safety rules that Saves.Copy and main's gather already keep: a commit the game still has waiting, the recovery of a swap the PC cut short, and the gather lock on the folders beside the save. Each can leave the player with the wrong saves, or none, on a path the PR adds.

For a player: one file to keep their saves in or carry to another PC, and a way to bring that file back with a backup made first. A real gain, and the code is mostly well built. The three gaps are in the one new code path that replaces the whole save folder. Each fix is small, and the simplest one is to reuse what Saves.Copy already does rather than keep a second copy of its swap.

Reviewed: a00d7d2d against main 8594b470 (the PR sits on current main, so no rebase was needed: it merges cleanly, including with #175 and #176). Read in full: Core/SaveArchive.cs, the Core/Saves.cs diff and the code it calls (Copy, CopyTree, DeleteTree, Beside, Real, Inside, PendingCommit, Gather/HoldGatherLock), HookshotSaves.Validate, the SavesViewModel.cs diff, MainWindow.axaml.cs, ViewModelBase.cs, both views, tests/launcher_core/SaveArchiveChecks.cs, tools/screenshots/Program.cs, docs/saves.md and README. Skimmed: the 12 catalogs (de and ja read line by line; the rest checked for the same keys). Nothing was run (a code review).
Fixed in this review: nothing.
Checked and fine:

  • Zip-slip: names with .., . or empty parts, a leading /, any : (drives, NTFS streams), control characters and backslashes are refused before anything is unpacked. Unpack checks again that every path stays inside its own folder.
  • Links: Unix symlink entries are refused, and the unpack writes plain files itself, so it never makes a link. The export leaves out links and junctions without following them and names them. A zip that is itself a link is refused.
  • Bombs: the zip is capped at 512 MB and 10,000 entries. The bytes that come out are counted as they are read (per file and in total), whatever the zip claims. A truncated zip, an entry that fails its CRC, or a zip that is not a zip is refused as InvalidDataException, and nothing is left behind.
  • Duplicates: a whole folder is deduplicated case-insensitively (a.txt/A.TXT is tested), and FileMode.CreateNew catches anything that gets past that. The save-files rule is case-sensitive, so Account.sav is refused.
  • The import shows what it will import: it unpacks once on the confirm page and imports from that copy, so a zip changed on disk in between changes nothing.
  • Backups: the whole save folder is copied to import-zip-<stamp> before anything moves, and a backup inside the save folder is refused. A save folder that is itself a link is resolved (Real), so the link stays.
  • Zips that aren't Longshot's (made by hand, Hookshot's, an emulator's, the PR's first format) go through HookshotSaves.Validate and Saves.Copy, so they get that function's pending-commit check, backup and swap.
  • What leaves the PC: only <user>/save. Not the settings beside it, and not the backups (save-backup and oot-save-backups are outside it). The comment holds the launcher's version, a UTC time and slot names: no user name and no paths. No game files.
  • The export is written to .longshot-part and renamed into place, and a failure deletes the part file. A zip inside the save folder is refused.
  • The screenshot tool writes only into its scene's fake environment. The translations cover all 12 catalogs, with the two replaced keys removed in every one. de and ja read well.
  • CI: the commit title check passed. Compile-and-test was skipped (it is started by hand). The author's runs: 1704 core checks and 37 release tests, on Windows 11.

Blocking (now on main: for a follow-up before the next stable)

  1. Core/SaveArchive.cs:94 and :435: neither ExportSave nor ImportWhole checks Saves.PendingCommit, and Saves.Copy refuses both sides on it. Say the game was closed mid-commit and left <user>/save-tx/ready-N (or save-import). The export then zips the save from before that commit, and the game loads the newer one. Worse, after a whole import the next start of the game applies the waiting commit over the imported folder, so the import is partly undone, quietly. Fix: before both, check PendingCommit(Path.Combine(saveFolder, Saves.UserId)) and throw SaveFailure(..., SaveRefusal.Waiting, ...) as Copy does. The result page already handles Waiting. Add a check with a save-tx/ready-1 folder.
  2. Core/SaveArchive.cs:439-486: the swap is a weaker copy of Saves.Copy's. (a) If the PC goes off between Directory.Move(real, aside) and Directory.Move(staging, real), the save folder is missing, and the player's saves are only in .save.longshot-old and the backup. The next ImportWhole then sees had == false, makes no backup, and DeleteTree(aside) (line 441) deletes them. Copy moves a left-over aside back first (Saves.cs 533). (b) If moving aside back fails (line 475), the outer catch still says "Nothing was changed: … is as it was" while the folder is missing. Copy tries Restore(backup, target) and says when it couldn't. Fix: move the aside back at the start, as Copy and Gather do, and share the swap with Copy (one helper used by both) instead of keeping two copies of it. Add a check for the cut-short case.
  3. Core/SaveArchive.cs:439: Beside(<user>/save) gives .save.longshot-staging/.save.longshot-old, the same two folders Gather uses (Saves.cs 724). #175's rule is that everything using them holds the gather lock (HoldGatherLock; doc comment on GatherAlone). ImportWhole doesn't hold it, so on Windows a gather started from a desktop shortcut's --play during an import can delete the staging folder, or move the aside folder back, mid-swap. Fix: using var held = Saves.HoldGatherLock(env); around the non-dry-run part.

Suggestions (the author may take or leave)

  • Core/SaveArchive.cs:122: line 120 resolves the folder with Real, then line 122 refuses a save folder that is itself a link. So a player who linked save to a synced folder can't export, though ImportWhole handles that case. Zipping the resolved folder would be consistent.
  • The export takes everything in the save folder, including .<id>.longshot-staging/.longshot-old, which Copy leaves there when it is cut short. They are stale saves rather than private data, but leaving out these dot-folders would keep stale copies out of the zip, and out of a later whole import.
  • Whole folders accept any name. Windows device names (CON, NUL, COM1) and parts ending in a dot or a space, made on Linux, behave oddly when unpacked on Windows. An explicit refusal would give a clear message instead.
  • Unpack runs on the UI thread from Refresh (up to 512 MB in theory). It is fine for real save folders, but moving it off the UI thread would keep a large hostile zip from freezing the window.
  • The checks don't cover a 7-Zip zip with LZMA or a password. I expect both are refused as InvalidDataException, but a check would pin that down, since only IO and data exceptions are caught in Refresh's path.

Questions

  • The two zip imports both name their backup import-zip-<stamp>, but one holds the whole save folder (profiles below it) and the other holds one profile (account.sav, slot_NN). Does #182's restore tell them apart? If not, import-zip-whole-<stamp> (or similar) would make the layout clear from the name.

Testing: the author ran the core checks and release tests on Windows 11. Nothing has been clicked through in the real window, and nothing has run on Linux or the Steam Deck. A Linux run of export, then a whole import, then starting the game is wanted. CI's compile-and-test was skipped (it is started by hand), so it should be run on main now. Missing from the checks: the pending commit, a swap cut short between its renames, and the gather lock.
Overlaps and merge order: this PR is merged; next comes #182 (restore from a backup), then #183 (one slot at a time), which is stacked on 182. No textual conflict with main now: the author's rebase onto 8594b47 resolved it. The interplay with #175 is point 3.

**Verdict: Request changes (posted after the merge).** This PR merged as 0e96947 (the same tree as a00d7d2d) while I was reviewing it, so the forge won't take a review any more, and this comes as a comment instead. The three blocking points below are now on main, and a follow-up fix should land before the next stable. The zip itself is built safely (zip-slip, links, bombs, duplicates and case clashes are all handled), but the whole-folder import and the export skip three save-safety rules that `Saves.Copy` and main's gather already keep: a commit the game still has waiting, the recovery of a swap the PC cut short, and the gather lock on the folders beside the save. Each can leave the player with the wrong saves, or none, on a path the PR adds. For a player: one file to keep their saves in or carry to another PC, and a way to bring that file back with a backup made first. A real gain, and the code is mostly well built. The three gaps are in the one new code path that replaces the whole save folder. Each fix is small, and the simplest one is to reuse what `Saves.Copy` already does rather than keep a second copy of its swap. **Reviewed:** a00d7d2d against main 8594b470 (the PR sits on current main, so no rebase was needed: it merges cleanly, including with https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/175 and https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/176). Read in full: `Core/SaveArchive.cs`, the `Core/Saves.cs` diff and the code it calls (`Copy`, `CopyTree`, `DeleteTree`, `Beside`, `Real`, `Inside`, `PendingCommit`, `Gather`/`HoldGatherLock`), `HookshotSaves.Validate`, the `SavesViewModel.cs` diff, `MainWindow.axaml.cs`, `ViewModelBase.cs`, both views, `tests/launcher_core/SaveArchiveChecks.cs`, `tools/screenshots/Program.cs`, `docs/saves.md` and README. Skimmed: the 12 catalogs (de and ja read line by line; the rest checked for the same keys). Nothing was run (a code review). **Fixed in this review:** nothing. **Checked and fine:** - Zip-slip: names with `..`, `.` or empty parts, a leading `/`, any `:` (drives, NTFS streams), control characters and backslashes are refused before anything is unpacked. Unpack checks again that every path stays inside its own folder. - Links: Unix symlink entries are refused, and the unpack writes plain files itself, so it never makes a link. The export leaves out links and junctions without following them and names them. A zip that is itself a link is refused. - Bombs: the zip is capped at 512 MB and 10,000 entries. The bytes that come out are counted as they are read (per file and in total), whatever the zip claims. A truncated zip, an entry that fails its CRC, or a zip that is not a zip is refused as `InvalidDataException`, and nothing is left behind. - Duplicates: a whole folder is deduplicated case-insensitively (`a.txt`/`A.TXT` is tested), and `FileMode.CreateNew` catches anything that gets past that. The save-files rule is case-sensitive, so `Account.sav` is refused. - The import shows what it will import: it unpacks once on the confirm page and imports from that copy, so a zip changed on disk in between changes nothing. - Backups: the whole save folder is copied to `import-zip-<stamp>` before anything moves, and a backup inside the save folder is refused. A save folder that is itself a link is resolved (`Real`), so the link stays. - Zips that aren't Longshot's (made by hand, Hookshot's, an emulator's, the PR's first format) go through `HookshotSaves.Validate` and `Saves.Copy`, so they get that function's pending-commit check, backup and swap. - What leaves the PC: only `<user>/save`. Not the settings beside it, and not the backups (`save-backup` and `oot-save-backups` are outside it). The comment holds the launcher's version, a UTC time and slot names: no user name and no paths. No game files. - The export is written to `.longshot-part` and renamed into place, and a failure deletes the part file. A zip inside the save folder is refused. - The screenshot tool writes only into its scene's fake environment. The translations cover all 12 catalogs, with the two replaced keys removed in every one. de and ja read well. - CI: the commit title check passed. Compile-and-test was skipped (it is started by hand). The author's runs: 1704 core checks and 37 release tests, on Windows 11. **Blocking** (now on main: for a follow-up before the next stable) 1. `Core/SaveArchive.cs:94` and `:435`: neither `ExportSave` nor `ImportWhole` checks `Saves.PendingCommit`, and `Saves.Copy` refuses both sides on it. Say the game was closed mid-commit and left `<user>/save-tx/ready-N` (or `save-import`). The export then zips the save from before that commit, and the game loads the newer one. Worse, after a whole import the next start of the game applies the waiting commit over the imported folder, so the import is partly undone, quietly. Fix: before both, check `PendingCommit(Path.Combine(saveFolder, Saves.UserId))` and throw `SaveFailure(..., SaveRefusal.Waiting, ...)` as `Copy` does. The result page already handles `Waiting`. Add a check with a `save-tx/ready-1` folder. 2. `Core/SaveArchive.cs:439-486`: the swap is a weaker copy of `Saves.Copy`'s. (a) If the PC goes off between `Directory.Move(real, aside)` and `Directory.Move(staging, real)`, the save folder is missing, and the player's saves are only in `.save.longshot-old` and the backup. The next `ImportWhole` then sees `had == false`, makes no backup, and `DeleteTree(aside)` (line 441) deletes them. `Copy` moves a left-over aside back first (`Saves.cs` 533). (b) If moving `aside` back fails (line 475), the outer catch still says "Nothing was changed: … is as it was" while the folder is missing. `Copy` tries `Restore(backup, target)` and says when it couldn't. Fix: move the aside back at the start, as `Copy` and `Gather` do, and share the swap with `Copy` (one helper used by both) instead of keeping two copies of it. Add a check for the cut-short case. 3. `Core/SaveArchive.cs:439`: `Beside(<user>/save)` gives `.save.longshot-staging`/`.save.longshot-old`, the same two folders `Gather` uses (`Saves.cs` 724). #175's rule is that everything using them holds the gather lock (`HoldGatherLock`; doc comment on `GatherAlone`). `ImportWhole` doesn't hold it, so on Windows a gather started from a desktop shortcut's `--play` during an import can delete the staging folder, or move the aside folder back, mid-swap. Fix: `using var held = Saves.HoldGatherLock(env);` around the non-dry-run part. **Suggestions** (the author may take or leave) - `Core/SaveArchive.cs:122`: line 120 resolves the folder with `Real`, then line 122 refuses a `save` folder that is itself a link. So a player who linked `save` to a synced folder can't export, though `ImportWhole` handles that case. Zipping the resolved folder would be consistent. - The export takes everything in the save folder, including `.<id>.longshot-staging`/`.longshot-old`, which `Copy` leaves there when it is cut short. They are stale saves rather than private data, but leaving out these dot-folders would keep stale copies out of the zip, and out of a later whole import. - Whole folders accept any name. Windows device names (`CON`, `NUL`, `COM1`) and parts ending in a dot or a space, made on Linux, behave oddly when unpacked on Windows. An explicit refusal would give a clear message instead. - `Unpack` runs on the UI thread from `Refresh` (up to 512 MB in theory). It is fine for real save folders, but moving it off the UI thread would keep a large hostile zip from freezing the window. - The checks don't cover a 7-Zip zip with LZMA or a password. I expect both are refused as `InvalidDataException`, but a check would pin that down, since only IO and data exceptions are caught in `Refresh`'s path. **Questions** - The two zip imports both name their backup `import-zip-<stamp>`, but one holds the whole `save` folder (profiles below it) and the other holds one profile (`account.sav`, `slot_NN`). Does https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/182's restore tell them apart? If not, `import-zip-whole-<stamp>` (or similar) would make the layout clear from the name. **Testing:** the author ran the core checks and release tests on Windows 11. Nothing has been clicked through in the real window, and nothing has run on Linux or the Steam Deck. A Linux run of export, then a whole import, then starting the game is wanted. CI's compile-and-test was skipped (it is started by hand), so it should be run on main now. Missing from the checks: the pending commit, a swap cut short between its renames, and the gather lock. **Overlaps and merge order:** this PR is merged; next comes https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/182 (restore from a backup), then https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/183 (one slot at a time), which is stacked on 182. No textual conflict with main now: the author's rebase onto 8594b47 resolved it. The interplay with https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/175 is point 3.
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!181
No description provided.