fix(saves): export to a folder with no save yet makes the save in it #166

Merged
HumanBean merged 1 commit from riqmarmes/LongshotLauncher:fix/saves-export-to-a-new-folder into main 2026-11-17 20:30:25 +00:00
Contributor

Why. Exporting a save to a folder that holds no save yet is refused, although the Saves page offers "A portable
emulator's user folder, or any folder"
and docs/saves.md says "or into any folder you pick with Choose a folder".
Saves → Export saves… → Another folder… → an empty folder leaves the confirm page saying "No save of the game
under … (a folder with account.sav and slot_
, or 0400486024DEC000 under an emulator's nand/user/save): start the game
there once and save."* with Export disabled. It only works when the folder already holds a save (or an emulator's
empty title folder) — so it cannot be used to keep a backup of your saves, and a portable emulator cannot be pointed at
a new folder before its first run. See #165.

What changed.

  • Core/Saves.cs — Saves.ExportTarget(program, folder, env). For an export whose other side is a folder
    (Saves.Folder), the folder needs no save: it becomes the save folder (SaveProfile(Base(folder), folder)), and the
    copy writes account.sav, option.sav and the slot folders there. Imports still use Locate (an empty folder has
    nothing to import), and an emulator's folder still must hold its save, since its saves live in its own layout. The top
    of a drive is refused with its own message: the copy puts the new save in place by moving a folder in beside the
    target, and a drive's top has no place beside it.
  • Saves.ImportExport resolves the other side with import ? Locate(…) : ExportTarget(…), and
    SavesConfirmViewModel.Refresh does the same, so the confirm page appears with the copy enabled.
  • Saves.Copy: a target with no save file in it has nothing to back up — SaveCopy.Backup is null and no empty
    backup folder is made, so the page says "Nothing there yet to back up." instead of offering a backup of an empty
    folder. The other files in the folder stay (the staging already copies everything but slot_*, account.sav and
    option.sav), and a target that did hold a save is still backed up whole before it is replaced.
  • docs/saves.md: says that a folder with no save is made into the save folder, and that what the save replaces is
    backed up.

Screenshots. No layout change. The confirm page for a new folder now appears with "Nothing there yet to back up."
and Export enabled, instead of the "No save of the game under …" problem and a disabled button. I can attach
before/after shots if wanted.

Testing.

  • python -I tests/test_launcher_core.py: 1448 checks passed (1440 on main; 8 new). The new checks cover: the
    preview of a new folder names it and changes nothing; the export makes account.sav, option.sav and slot_00/
    slot_01 there with no backup and no backup folder; that folder is the save folder afterwards; a second export to it
    is backed up and replaces it; a folder with other files keeps them beside the save; an emulator's folder with no save
    is still refused; a missing folder still says "No folder"; the top of a drive is refused.
  • python -m pytest tests/test_release.py: 37 passed, 11 subtests.
  • dotnet build LongshotLauncher.slnx: 0 warnings, 0 errors.
  • In the launcher, Windows 11, the dev build of this branch: Saves → Export saves… → Another folder… → a new empty
    folder → the confirm page appears; Export writes account.sav, option.sav and the slot folders into it; exporting
    again offers the backup of that save. Not tested: Linux (the change is Core/ plus one line of a view model; the
    checks run on Linux in CI).

Risks. What could break: nothing in the save format, longshot_options.ini, the shader and pipeline caches, the vk
ABI or the builder's tools. Locate is untouched, so imports and every emulator destination behave as before; only the
folder the player picks for an export may now be new, and only then does the launcher write save files where the player
pointed (which is the change). Turning it off: revert the commit; the old behaviour is the Locate rule.
Compatibility: saves, longshot_options.ini, the caches, the vk ABI and the builder's tools are unchanged.

A note on the shared rule. Core/Saves.cs is a port of scripts/longshot_saves.py, and the script still refuses a
--to folder with no save (its side() calls locate(), and new_save_folder() returns nothing for FOLDER). This
change is the launcher's rule for the folder the player picks in the window, where the page and the docs already promise
"any folder". If you want one rule across both, say so and I will send the script change too (a new_save_folder entry
for FOLDER plus a test).

Fixes #165

**Why.** Exporting a save to a folder that holds no save yet is refused, although the Saves page offers *"A portable emulator's user folder, or any folder"* and `docs/saves.md` says *"or into any folder you pick with Choose a folder"*. Saves → **Export saves…** → **Another folder…** → an empty folder leaves the confirm page saying *"No save of the game under … (a folder with account.sav and slot_*, or 0400486024DEC000 under an emulator's nand/user/save): start the game there once and save."* with **Export** disabled. It only works when the folder already holds a save (or an emulator's empty title folder) — so it cannot be used to keep a backup of your saves, and a portable emulator cannot be pointed at a new folder before its first run. See #165. **What changed.** - **`Core/Saves.cs` — `Saves.ExportTarget(program, folder, env)`.** For an export whose other side is a folder (`Saves.Folder`), the folder needs no save: it becomes the save folder (`SaveProfile(Base(folder), folder)`), and the copy writes `account.sav`, `option.sav` and the slot folders there. Imports still use `Locate` (an empty folder has nothing to import), and an emulator's folder still must hold its save, since its saves live in its own layout. The top of a drive is refused with its own message: the copy puts the new save in place by moving a folder in beside the target, and a drive's top has no place beside it. - **`Saves.ImportExport`** resolves the other side with `import ? Locate(…) : ExportTarget(…)`, and **`SavesConfirmViewModel.Refresh`** does the same, so the confirm page appears with the copy enabled. - **`Saves.Copy`:** a target with no save file in it has nothing to back up — `SaveCopy.Backup` is null and no empty backup folder is made, so the page says *"Nothing there yet to back up."* instead of offering a backup of an empty folder. The other files in the folder stay (the staging already copies everything but `slot_*`, `account.sav` and `option.sav`), and a target that did hold a save is still backed up whole before it is replaced. - **`docs/saves.md`:** says that a folder with no save is made into the save folder, and that what the save replaces is backed up. **Screenshots.** No layout change. The confirm page for a new folder now appears with *"Nothing there yet to back up."* and **Export** enabled, instead of the "No save of the game under …" problem and a disabled button. I can attach before/after shots if wanted. **Testing.** - `python -I tests/test_launcher_core.py`: **1448 checks passed** (1440 on `main`; 8 new). The new checks cover: the preview of a new folder names it and changes nothing; the export makes `account.sav`, `option.sav` and `slot_00`/ `slot_01` there with no backup and no backup folder; that folder is the save folder afterwards; a second export to it is backed up and replaces it; a folder with other files keeps them beside the save; an emulator's folder with no save is still refused; a missing folder still says "No folder"; the top of a drive is refused. - `python -m pytest tests/test_release.py`: 37 passed, 11 subtests. - `dotnet build LongshotLauncher.slnx`: 0 warnings, 0 errors. - **In the launcher**, Windows 11, the dev build of this branch: Saves → Export saves… → Another folder… → a new empty folder → the confirm page appears; Export writes `account.sav`, `option.sav` and the slot folders into it; exporting again offers the backup of that save. Not tested: Linux (the change is `Core/` plus one line of a view model; the checks run on Linux in CI). **Risks.** What could break: nothing in the save format, `longshot_options.ini`, the shader and pipeline caches, the vk ABI or the builder's tools. `Locate` is untouched, so imports and every emulator destination behave as before; only the folder the player picks for an export may now be new, and only then does the launcher write save files where the player pointed (which is the change). Turning it off: revert the commit; the old behaviour is the `Locate` rule. **Compatibility:** saves, `longshot_options.ini`, the caches, the vk ABI and the builder's tools are unchanged. **A note on the shared rule.** `Core/Saves.cs` is a port of `scripts/longshot_saves.py`, and the script still refuses a `--to` folder with no save (its `side()` calls `locate()`, and `new_save_folder()` returns nothing for `FOLDER`). This change is the launcher's rule for the folder the player picks in the window, where the page and the docs already promise "any folder". If you want one rule across both, say so and I will send the script change too (a `new_save_folder` entry for `FOLDER` plus a test). Fixes #165
fix(saves): export to a folder with no save yet makes the save in it
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Compile and test (pull_request) Blocked by required conditions
0e5b7c45b0
The Saves page's export offers "A portable emulator's user folder, or any folder"
and docs/saves.md says "any folder you pick", but the destination was resolved
with Saves.Locate, which requires an existing save: an empty folder made the
confirm page say "No save of the game under ..." and left Export disabled.

Saves.ExportTarget resolves the folder the player chose for an export without
requiring a save (the export makes it the save folder); imports and emulator
destinations keep Locate's rule. Saves.Copy reports no backup for a target that
holds no save file, so the confirm page says "Nothing there yet to back up."
instead of offering a backup of an empty folder.

Tests: python -I tests/test_launcher_core.py (1448 checks passed, 8 new);
python -m pytest tests/test_release.py (37 passed, 11 subtests);
dotnet build LongshotLauncher.slnx.

Assisted-by: DeepSeek Harness
Collaborator

Possibly related, for context:

  • PR #26 feat: redesign save management around slots and transfers — Earlier save-management redesign disabled export for empty saves; this changes that behavior.
Possibly related, for context: - PR #26 feat: redesign save management around slots and transfers — Earlier save-management redesign disabled export for empty saves; this changes that behavior.
Author
Contributor

Replying to the related-changes note: #26 disabled export when Longshot has no save slots (SavesViewModel.ExportCommand
is () => Slots.Count > 0), and that stays exactly as it is — this pull request never enables the button without a save
to export.

What changes is the destination side only: the folder chosen with Another folder… may be one that holds no save yet,
which the picker ("A portable emulator's user folder, or any folder") and docs/saves.md ("or into any folder you
pick") already promise. An emulator's destination still has to hold its save, because the copy writes into the layout the
emulator reads. If the old refusal of a new folder was deliberate rather than a gap, say so and I will change the wording
instead; the question is in #165.

Replying to the related-changes note: #26 disabled export when Longshot has no save slots (`SavesViewModel.ExportCommand` is `() => Slots.Count > 0`), and that stays exactly as it is — this pull request never enables the button without a save to export. What changes is the destination side only: the folder chosen with *Another folder…* may be one that holds no save yet, which the picker ("A portable emulator's user folder, or any folder") and `docs/saves.md` ("or into any folder you pick") already promise. An emulator's destination still has to hold its save, because the copy writes into the layout the emulator reads. If the old refusal of a new folder was deliberate rather than a gap, say so and I will change the wording instead; the question is in #165.
HumanBean deleted branch fix/saves-export-to-a-new-folder 2026-11-17 20:30:26 +00:00
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Compile and test (pull_request) Blocked by required conditions
Some workflows are waiting to be reviewed.
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!166
No description provided.