fix(saves): a build started on its own reads the shared saves through a link, so the launcher stops moving its folder #196

Merged
HumanBean merged 2 commits from mooki/LongshotLauncher:fix/saves-shared-link into main 2026-11-18 02:31:03 +00:00
Member

Type: fix · Risk: medium · Tested on: Linux (Arch, kernel 7.2.15), .NET SDK 10.0.113: the launcher's core tests (2,045 checks; main's own Linux failure skipped in a scratch copy), its release tests, a build of the whole solution; no Windows PC · Needs: Windows (a junction on NTFS, and a game started on its own through it)

TL;DR

On Windows, a Longshot started any way but the launcher's Play (bin\longshot.exe, a taskbar pin, Steam) keeps its saves in its own folder, and every time the launcher opened it renamed that folder to save.moved-…, so the game found no saves (Longshot#639). Now the launcher leaves a link to the shared saves in its place, so that game plays the same saves and nothing is left to move. The new checks fail on main and pass here, and a game-free harness shows main moving the folder at every start and this branch moving it once. It is not run on Windows: the link itself still needs that.

Breakdown

  • Who it helps: Windows players who start Longshot other than through the launcher's Play (a pinned longshot.exe, Steam, an old Builder's shortcut), with the installed launcher or a portable one. The reports on Longshot#639 (Windows 10 nightly 170, installed; Windows 11 v3.0.0-rc.5, portable) are this; #146 ("updating deleted all saves") is probably the same chain seen from the other end, as #175 says.
  • What was wrong: the launcher starts a game with --user <shared folder>, a game started on its own has no --user and saves in <game folder>\user\save. Saves.Gather runs when the launcher opens and before every Play and treats every build's user\save as an old save: it merges it into the shared one and renames it save.moved-<stamp>. It is not a one-time migration. The game started on its own finds no save, begins a new one, and the next start moves that too.
  • What changes: where Gather renames a save aside it leaves a link to the shared save (a junction on Windows) at user\save; Saves.LinkSaves makes the same link in a game folder that has no user\save, or only the game's own options (set aside first), when the launcher opens and before Play. The game started on its own then reads and writes the shared saves.
  • What does not change: Linux and the Steam Deck (the game shares the saves by itself there); the merge and backup rules of Gather (#175) and of Delete (#176); a user\ or user\save that is the player's own link is left alone; a folder that still holds a save is Gather's, not the link's; no new text, no setting.
  • How it was checked: tests written first and failing on main; the launcher's whole core test run (2,008 checks on main, 2,045 here) and its release tests; 13 versions broken on purpose; a game-free harness that plays the game started on its own and the launcher's starts in turn on main and on this branch; the whole solution builds.
  • What is still open: a Windows run (the junction, and the game started on its own through it); NTFS-less disks, shares, OneDrive; whether the game should also default --user for a folder the launcher made (Questions).
  • Risk: medium. If a junction were made wrong the game would save somewhere else; the launcher reads the link back and takes it away again unless it names the shared save, and a link that cannot be made leaves the folder as it was before this change.

Why

Longshot#639 (Windows 10, nightly 170): "Every time you launch Longshot through the launcher it moves your saves for no reason and you have to move them back." A second report on it (Windows 11, v3.0.0-rc.5, portable launcher) found save.moved-20261117-083238 after opening the launcher, and the saves intact in LongshotLauncher-data\user\save\<user id>. The chain, at launcher a6bcd88 and Longshot main 257c54911 (the lines quoted are at those commits; host/hos_main.c moved four lines since I first read it, and what it does here did not change):

  1. The game takes --user <dir> as its user folder (host/hos_main.c:2030). Without it a game folder's Windows game uses <exe folder>\user (:2055-2072). Its save (<user>\save\<user id>) and its temp folder (<user>\temp) are mounted under that folder (host/nn_fs.c:270-272, :303). Longshot's guide says it: "Starting longshot.exe directly without --user does not use the launcher's shared save folder" (docs/saves.md:110).
  2. The launcher passes --user only when it starts the game: Core/MakeGameCommand.cs:240-242 (UserFolder: %APPDATA%\Longshot, a portable launcher's LongshotLauncher-data\user), :260-264, from App/LauncherService.cs:252-273 (PlayFolder: Play, the Ready screen, the shortcut's --play).
  3. The migration runs at every start: App/App.axaml.cs:52 (the window opens) and App/LauncherService.cs:254 (before every Play) call GatherSaves() (:344-356), which runs Saves.Gather over Saves.OldUserFolders (Core/Saves.cs:689-700): every build's <folder>\user, and the 2.x Builder's. A folder holding a save and no link counts as old (:746-748), is merged into the shared save and then renamed save.moved-<stamp> (:843-848).
  4. So the game started on its own loops: it writes user\save, the next launcher start renames it, the same game started again finds none, begins a new one, and that is moved at the start after. What the player moves back is moved again. Nothing in the launcher creates <build>\user\save (no code writes it), so the loop needs a start without --user.
  5. The screenshot in #639 fits: the build's user folder holds temp, save (8:48 PM) and two save.moved-… (stamps 20:04:39 and 20:15:59, their contents last written 7:41 PM and 8:06 PM). user\temp and user\save appear in the build's folder only when the game had that folder as its user folder (nn_fs.c); a game the launcher starts writes them in %APPDATA%\Longshot. That is three starts without --user and two launcher starts that moved their saves. (Inferred: the folder named save inside Roaming\Longshot\save in the same picture is the player's own attempt to move one back, one level too deep: the shared folder holds the <user id> folder directly.)
  6. Ruled out: a launcher-only loop. The shared folder is never an old folder (OldUserFolders compares without case, Gather also compares resolved paths); a tie keeps the shared save; a portable and an installed launcher have separate builds.json and different shared folders, so flipping between them does not make a build's folder old.

#175 (merged today) stopped the data loss in this chain: slots are merged, never replaced, and everything is backed up first. It does not stop the rename, so the game started on its own still finds no save at its next start.

How to reproduce

Seen on: two reports on Longshot#639 (Windows 10 with nightly 170 and the installed launcher; Windows 11 with v3.0.0-rc.5 and a portable launcher). Not run on a Windows PC here: reproduced game-free, below.
Settings and switches: defaults
Steps: build a version with the launcher; start it once by double-clicking bin\longshot.exe in its folder and save; open the launcher (or press Play in it); start bin\longshot.exe again
Expected: the game finds the save it made
Actual: it finds none; user\save.moved-<yyyyMMdd-HHmmss> has appeared beside a new user\save; each further launcher start moves the new one too

What changed

  • Core/Saves.cs: Gather makes a link to the shared save at the user\save it renamed aside (MakeLink, which reads the link back and takes it away again unless it names the shared save and can be read). New LinkSaves(env, gameFolders, running, now): for each game folder (not a game folder, or not there: skipped) it plans one of nothing, heal (the shared save folder a link names is gone: made again), make (no user\save), aside then make (a folder with no save in it, only the game's options: renamed save.moved-<stamp>, nothing deleted), empty (an empty folder replaced), repoint (a portable launcher's link whose folder moved, recognised by LongshotLauncher-data\user\save at the end of what it names and by naming nothing). Left alone: a user\ that is a link, a link the player made, a folder that holds a save (Gather's), the shared save itself or a folder in or holding it. It does nothing while Longshot runs or when another launcher holds the gather lock (the next start tries again), and never throws. LinksToShared says whether a path is the launcher's own link. Each link made, set aside for or not made is a line in the launcher's log (saves link: …), as #171 asks of what the launcher does to the player's data.
  • Core/FileLinks.cs: TryDirectoryLink (a junction through FSCTL_SET_REPARSE_POINT on Windows, which needs no privilege; a symbolic link elsewhere or where the junction fails; nothing left behind when none is made) and JunctionData (the reparse buffer, a pure function with its own check).
  • Core/Leftovers.cs, App/LauncherService.cs: Leftovers.Find takes the save environment and counts the launcher's own link as nothing of the player's, so old versions are offered for deletion as before; GatherSaves links every build's folder after the gather, and PlayFolder the folder it starts.
  • docs/saves.md, README.md: how a build started on its own behaves now.
  • tests: tests/launcher_core/SavesChecks.cs (GatherLink, LinkSavesChecks; the merge checks of #175 run with the link switched off, because they put a plain user\save in again after each start, as a disk with no junctions would), LeftoverChecks.cs.

Unchanged on purpose: Linux and the Steam Deck; what Gather merges, backs up and renames; Delete (#176, which already takes a link and never follows it); the notice the home shows (no new text, so no catalog change).

How it was tested

Everything here was run by an AI agent (Claude Sonnet 5.5) working for me; the commands are given so anyone can rerun them. No Windows PC and no game were used: every check is game-free, on Linux.

Environment: Arch Linux, kernel 7.2.15, .NET SDK 10.0.113 (the repository pins 10.0.404, which this PC does not have: global.json was changed locally for the runs and is not in the branch), 17 Nov 2026, base a6bcd88 (launcher main), head aabeae1, load average 20 to 47 from other jobs on the PC (correctness checks only, nothing timed).

  1. Reading first. The #639 issue, its comment and timeline, and its picture were read through the forge's public API; launcher #146, #175 and #176 and Longshot #1397 (the saves script's Windows default) too. The launcher was read at a6bcd88 (the places above) and Longshot's host/hos_main.c, host/nn_fs.c and docs/saves.md at main 257c54911. The picture was looked at: it shows the build's user folder with save, two save.moved-… and temp, and Roaming\Longshot\save holding a folder save.
  2. Tests first. Commit 1 (099183c) adds only the new checks GatherLink to tests/launcher_core/SavesChecks.cs. Run against main's code it fails at the second of them (the first, "Taken in as before", passes on main):
    Unhandled exception. System.Exception: saves: user\save is then a link to the shared save: a game started on its own finds the saves there.
    
    (python -I tests/test_launcher_core.py --dotnet dotnet from the checkout, through the workbench's idle-class gate, https://github.com/mooki000/ls-workbench.) The checks for LinkSaves, Leftovers and the junction data call code that main does not have, so they cannot fail on it: they are covered by the mutations below.
  3. The whole core suite. On this PC the suite stops at tests/launcher_core/BuildReportChecks.cs:70 on plain main a6bcd88 as well ("The home folder taken out before a line is cut", added by #164, whose description says Linux was not run: its line has 290 characters before the made-up Linux home folder, which the Linux rule does not take for the home folder, while the check expects ~). Every saves check, earlier in the run, passes before it. For totals I ran main and this head in scratch copies with that one expectation skipped on Linux (!OperatingSystem.IsWindows() || in front of it; nothing of it is in this branch): main a6bcd88 2,008 checks passed, this head 2,045 (the same suite plus this branch's checks). Without the skip both stop at that same check. The release tests (python -I tests/test_release.py, needs openssl): 37 tests OK.
  4. 13 versions broken on purpose, each in a copy of the tree (with the same skip), one rule each, and the core suite run on each; the first failing check is quoted (a mutation that only fails to compile would not count; none did):
# One rule broken First failing check
M1 Gather leaves no link "user\save is then a link to the shared save: a game started on its own finds the saves there."
M2 a folder with a save in it is taken aside and linked "A folder with a save in it, a link of the player's own, and a user\ that is a link are left alone."
M3 a user\ that is a link is not left alone "A folder with a save in it, a link of the player's own, and a user\ that is a link are left alone."
M4 any dangling link is made again, not only a portable launcher's "A portable launcher's link whose folder moved is made again at the new place; a dangling link of the player's own is left."
M5 the shared save folder is not made again "A link whose shared save folder is gone: the folder is made again, the link kept."
M6 no gather lock "Another gather holds the lock: nothing is changed, nothing fails."
M7 links while Longshot runs "Not while Longshot runs: the next start tries again."
M8 the launcher's own link is the player's own, for leftovers "A folder with the launcher's own link to the shared save is offered; the player's own link, and mods, keep one."
M9 junction data: the print name's offset is wrong "The junction's reparse data: a mount point, the target as the system and the player name it, each ended by a zero."
M10 a link that does not name the shared save is kept "A link that does not name the shared save is taken away again."
M11 a link to nothing is not taken away on Unix "A portable launcher's link whose folder moved is made again at the new place; a dangling link of the player's own is left."
M12 a folder with only options is not set aside, it is deleted DirectoryNotFoundException in the check that reads the set-aside file (the folder was deleted, not set aside)
M13 the shared save itself may be set aside and linked "A game folder whose user\save is the shared save itself is left alone: never set aside, never a link to itself."
  1. A game-free reproduction of the loop (a throwaway harness, not in the branch, attachable on request: the launcher's Core/ compiled with a program of 70 lines; the dates are its own clock). It plays the game started on its own (a stand-in that reads <build>\user\save\<user id>\slot_00\progress.sav: where there is none it begins a new game, where there is one it plays on) and the launcher's starts (Saves.OldUserFolders and Saves.Gather, and on the branch Saves.LinkSaves) in turn, four rounds, on made-up folders of a simulated Windows environment under a temporary folder. The same program on main a6bcd88 and on this head:

    main a6bcd88:

    round | the game started on its own | the launcher starts: | user\ of the build holds | shared save's slots
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    1     | finds NO save, begins a new game     | takes 1 folder in, renames it save.moved-*                     | save.moved-20261114-201000                              | slot_00="new game 20:00"
    2     | finds NO save, begins a new game     | takes 1 folder in, renames it save.moved-*                     | save.moved-20261114-201000 save.moved-20261114-204000   | slot_00="new game 20:00" slot_01="new game 20:30"
    3     | finds NO save, begins a new game     | takes 1 folder in, renames it save.moved-*                     | save.moved-20261114-201000 save.moved-20261114-204000 save.moved-20261114-211000 | slot_00="new game 20:00" slot_01="new game 20:30" slot_02="new game 21:00"
    4     | finds NO save, begins a new game     | takes 1 folder in, renames it save.moved-*                     | save.moved-20261114-201000 save.moved-20261114-204000 save.moved-20261114-211000 save.moved-20261114-214000 | slot_00="new game 20:00" slot_01="new game 20:30" slot_02="new game 21:00" slot_03="new game 21:30"
    

    this head aabeae1:

    round | the game started on its own | the launcher starts: | user\ of the build holds | shared save's slots
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    1     | finds NO save, begins a new game     | takes 1 folder in, renames it save.moved-*                     | save(link) save.moved-20261114-201000                   | slot_00="new game 20:00"
    2     | finds its save and plays on          | takes nothing in                                               | save(link) save.moved-20261114-201000                   | slot_00="new game 20:00+"
    3     | finds its save and plays on          | takes nothing in                                               | save(link) save.moved-20261114-201000                   | slot_00="new game 20:00++"
    4     | finds its save and plays on          | takes nothing in                                               | save(link) save.moved-20261114-201000                   | slot_00="new game 20:00+++"
    
  2. The whole solution builds: dotnet build LongshotLauncher.slnx --configuration Release: 0 warnings, 0 errors (Core, App, screenshots tool). The repository's own command, with -p:RestoreLockedMode=true, stops with NU1004 on this PC on plain main as well (its lock files name Microsoft.NET.ILLink.Tasks and win-x64, which SDK 10.0.113 does not resolve the same way), so the build above is without locked restore; the lock files were left as they are in the branch.

  3. Whitespace: git diff --check on the branch: clean. No game file, save, key or build output is in the branch (git status clean; the checks make their own text-file saves).

Not tested

  • Windows, all of it. Creating the junction (FSCTL_SET_REPARSE_POINT with the buffer JunctionData builds) on a real NTFS volume, .NET reading it back (DirectoryInfo.LinkTarget, ResolveLinkTarget) and the game started on its own with a junction as user\save: saving, loading, the game's atomic writes through it. The Windows-specific code is compiled here (the solution builds) and its buffer is checked byte for byte, but never run.
  • Disks with no junctions (FAT, exFAT, a share) and a game folder in OneDrive or Dropbox; a profile folder on a share; ReFS.
  • A real launcher upgrade from rc.3 and rc.4 folders; the 2.x Builder's folder.
  • Steam, a taskbar pin and Explorer starts of a real game (the harness stands in for the game).

Risks

  • A junction made wrong would send a game's saves to the wrong folder: MakeLink reads it back and takes it away again unless it names the shared save, and that check is tested with a link made to another folder. A link that cannot be made leaves what a gather left before this change.
  • A junction in a game folder is new to every Windows player who takes this update. Deleting such a folder should remove the junction and not what it names, in the launcher (its delete never follows a link, checked on Linux with the link of this branch and #176's own check), and in Explorer or with rd /s (Windows' own tools: not tried here); no junction was deleted on Windows.
  • LinkSaves writes in every build's folder when the window opens: one junction per build the first time, a few stat calls after.
  • With player profiles (#55) a build's link names the shared save of the player selected when it was made; another player's Play leaves it (it is not "the shared save" of that one). A game started on its own then uses the first player's saves.
  • The link is the launcher's, so deleting %APPDATA%\Longshot\save by hand leaves it naming nothing until the next start remakes the folder.

Overlaps

The 8 open launcher pull requests were listed and their files read (pulls/N/files); each of the 7 that share a file with this one (#49, #50, #55, #59, #151, #183, #189) was fetched at its current head and trial-merged (git merge-tree --write-tree) against main a6bcd88 and against this branch, and the conflicting files and the conflict hunks of the shared files were compared for both, since only a conflict that appears with this branch counts. Six of them (#50, #55, #59, #151, #183, #189) conflict with main already, in the same files and hunks with or without this branch (their bases are older than main); #49 merges cleanly with both. One extra hunk appears with this branch: #55, in App/LauncherService.cs, PlayFolder (this branch's LinkSaves line next to #55's UserFolderOf(folder)); keeping both resolves it.

Questions for you

  1. Should the game also default --user to the launcher's shared folder for a game folder the launcher made (a key in longshot_version.txt)? That would need no junction for builds made after it, and would not help the builds that exist now (nightly 170 and every rc built so far), which is why this fixes it in the launcher first.
  2. Should the home say once that a build now shares its saves through a link? It says nothing today (no new text, no catalog change); the notice of #175 still appears when a gather took something in.
  3. A portable launcher's link names the portable folder's absolute path and is made again when the folder moves (the start after the move). Is that acceptable, or should a portable launcher get no link?

New on this forge; not opened on GitHub.

**Type:** fix · **Risk:** medium · **Tested on:** Linux (Arch, kernel 7.2.15), .NET SDK 10.0.113: the launcher's core tests (2,045 checks; main's own Linux failure skipped in a scratch copy), its release tests, a build of the whole solution; no Windows PC · **Needs:** Windows (a junction on NTFS, and a game started on its own through it) ## TL;DR On Windows, a Longshot started any way but the launcher's Play (`bin\longshot.exe`, a taskbar pin, Steam) keeps its saves in its own folder, and every time the launcher opened it renamed that folder to `save.moved-…`, so the game found no saves (Longshot#639). Now the launcher leaves a link to the shared saves in its place, so that game plays the same saves and nothing is left to move. The new checks fail on main and pass here, and a game-free harness shows main moving the folder at every start and this branch moving it once. It is not run on Windows: the link itself still needs that. ## Breakdown - **Who it helps:** Windows players who start Longshot other than through the launcher's Play (a pinned `longshot.exe`, Steam, an old Builder's shortcut), with the installed launcher or a portable one. The reports on Longshot#639 (Windows 10 nightly 170, installed; Windows 11 v3.0.0-rc.5, portable) are this; #146 ("updating deleted all saves") is probably the same chain seen from the other end, as #175 says. - **What was wrong:** the launcher starts a game with `--user <shared folder>`, a game started on its own has no `--user` and saves in `<game folder>\user\save`. `Saves.Gather` runs when the launcher opens and before every Play and treats every build's `user\save` as an old save: it merges it into the shared one and renames it `save.moved-<stamp>`. It is not a one-time migration. The game started on its own finds no save, begins a new one, and the next start moves that too. - **What changes:** where `Gather` renames a save aside it leaves a link to the shared save (a junction on Windows) at `user\save`; `Saves.LinkSaves` makes the same link in a game folder that has no `user\save`, or only the game's own options (set aside first), when the launcher opens and before Play. The game started on its own then reads and writes the shared saves. - **What does not change:** Linux and the Steam Deck (the game shares the saves by itself there); the merge and backup rules of `Gather` (#175) and of Delete (#176); a `user\` or `user\save` that is the player's own link is left alone; a folder that still holds a save is Gather's, not the link's; no new text, no setting. - **How it was checked:** tests written first and failing on main; the launcher's whole core test run (2,008 checks on main, 2,045 here) and its release tests; 13 versions broken on purpose; a game-free harness that plays the game started on its own and the launcher's starts in turn on main and on this branch; the whole solution builds. - **What is still open:** a Windows run (the junction, and the game started on its own through it); NTFS-less disks, shares, OneDrive; whether the game should also default `--user` for a folder the launcher made (Questions). - **Risk:** medium. If a junction were made wrong the game would save somewhere else; the launcher reads the link back and takes it away again unless it names the shared save, and a link that cannot be made leaves the folder as it was before this change. ## Why Longshot#639 (Windows 10, nightly 170): "Every time you launch Longshot through the launcher it moves your saves for no reason and you have to move them back." A second report on it (Windows 11, v3.0.0-rc.5, portable launcher) found `save.moved-20261117-083238` after opening the launcher, and the saves intact in `LongshotLauncher-data\user\save\<user id>`. The chain, at launcher `a6bcd88` and Longshot main `257c54911` (the lines quoted are at those commits; `host/hos_main.c` moved four lines since I first read it, and what it does here did not change): 1. **The game** takes `--user <dir>` as its user folder (`host/hos_main.c:2030`). Without it a game folder's Windows game uses `<exe folder>\user` (`:2055-2072`). Its save (`<user>\save\<user id>`) and its temp folder (`<user>\temp`) are mounted under that folder (`host/nn_fs.c:270-272`, `:303`). Longshot's guide says it: "Starting `longshot.exe` directly without `--user` does not use the launcher's shared save folder" (`docs/saves.md:110`). 2. **The launcher passes `--user` only when it starts the game:** `Core/MakeGameCommand.cs:240-242` (`UserFolder`: `%APPDATA%\Longshot`, a portable launcher's `LongshotLauncher-data\user`), `:260-264`, from `App/LauncherService.cs:252-273` (`PlayFolder`: Play, the Ready screen, the shortcut's `--play`). 3. **The migration runs at every start:** `App/App.axaml.cs:52` (the window opens) and `App/LauncherService.cs:254` (before every Play) call `GatherSaves()` (`:344-356`), which runs `Saves.Gather` over `Saves.OldUserFolders` (`Core/Saves.cs:689-700`): every build's `<folder>\user`, and the 2.x Builder's. A folder holding a save and no link counts as old (`:746-748`), is merged into the shared save and then renamed `save.moved-<stamp>` (`:843-848`). 4. **So the game started on its own loops:** it writes `user\save`, the next launcher start renames it, the same game started again finds none, begins a new one, and that is moved at the start after. What the player moves back is moved again. Nothing in the launcher creates `<build>\user\save` (no code writes it), so the loop needs a start without `--user`. 5. **The screenshot in #639 fits:** the build's `user` folder holds `temp`, `save` (8:48 PM) and two `save.moved-…` (stamps 20:04:39 and 20:15:59, their contents last written 7:41 PM and 8:06 PM). `user\temp` and `user\save` appear in the build's folder only when the game had that folder as its user folder (`nn_fs.c`); a game the launcher starts writes them in `%APPDATA%\Longshot`. That is three starts without `--user` and two launcher starts that moved their saves. (Inferred: the folder named `save` inside `Roaming\Longshot\save` in the same picture is the player's own attempt to move one back, one level too deep: the shared folder holds the `<user id>` folder directly.) 6. **Ruled out:** a launcher-only loop. The shared folder is never an old folder (`OldUserFolders` compares without case, `Gather` also compares resolved paths); a tie keeps the shared save; a portable and an installed launcher have separate `builds.json` and different shared folders, so flipping between them does not make a build's folder old. #175 (merged today) stopped the data loss in this chain: slots are merged, never replaced, and everything is backed up first. It does not stop the rename, so the game started on its own still finds no save at its next start. ## How to reproduce **Seen on:** two reports on Longshot#639 (Windows 10 with nightly 170 and the installed launcher; Windows 11 with v3.0.0-rc.5 and a portable launcher). Not run on a Windows PC here: reproduced game-free, below. **Settings and switches:** defaults **Steps:** build a version with the launcher; start it once by double-clicking `bin\longshot.exe` in its folder and save; open the launcher (or press Play in it); start `bin\longshot.exe` again **Expected:** the game finds the save it made **Actual:** it finds none; `user\save.moved-<yyyyMMdd-HHmmss>` has appeared beside a new `user\save`; each further launcher start moves the new one too ## What changed - `Core/Saves.cs`: `Gather` makes a link to the shared save at the `user\save` it renamed aside (`MakeLink`, which reads the link back and takes it away again unless it names the shared save and can be read). New `LinkSaves(env, gameFolders, running, now)`: for each game folder (not a game folder, or not there: skipped) it plans one of nothing, heal (the shared save folder a link names is gone: made again), make (no `user\save`), aside then make (a folder with no save in it, only the game's options: renamed `save.moved-<stamp>`, nothing deleted), empty (an empty folder replaced), repoint (a portable launcher's link whose folder moved, recognised by `LongshotLauncher-data\user\save` at the end of what it names and by naming nothing). Left alone: a `user\` that is a link, a link the player made, a folder that holds a save (`Gather`'s), the shared save itself or a folder in or holding it. It does nothing while Longshot runs or when another launcher holds the gather lock (the next start tries again), and never throws. `LinksToShared` says whether a path is the launcher's own link. Each link made, set aside for or not made is a line in the launcher's log (`saves link: …`), as #171 asks of what the launcher does to the player's data. - `Core/FileLinks.cs`: `TryDirectoryLink` (a junction through `FSCTL_SET_REPARSE_POINT` on Windows, which needs no privilege; a symbolic link elsewhere or where the junction fails; nothing left behind when none is made) and `JunctionData` (the reparse buffer, a pure function with its own check). - `Core/Leftovers.cs`, `App/LauncherService.cs`: `Leftovers.Find` takes the save environment and counts the launcher's own link as nothing of the player's, so old versions are offered for deletion as before; `GatherSaves` links every build's folder after the gather, and `PlayFolder` the folder it starts. - `docs/saves.md`, `README.md`: how a build started on its own behaves now. - tests: `tests/launcher_core/SavesChecks.cs` (`GatherLink`, `LinkSavesChecks`; the merge checks of #175 run with the link switched off, because they put a plain `user\save` in again after each start, as a disk with no junctions would), `LeftoverChecks.cs`. Unchanged on purpose: Linux and the Steam Deck; what `Gather` merges, backs up and renames; Delete (#176, which already takes a link and never follows it); the notice the home shows (no new text, so no catalog change). ## How it was tested Everything here was run by an AI agent (Claude Sonnet 5.5) working for me; the commands are given so anyone can rerun them. **No Windows PC and no game were used**: every check is game-free, on Linux. Environment: Arch Linux, kernel 7.2.15, .NET SDK 10.0.113 (the repository pins 10.0.404, which this PC does not have: `global.json` was changed locally for the runs and is not in the branch), 17 Nov 2026, base `a6bcd88` (launcher main), head `aabeae1`, load average 20 to 47 from other jobs on the PC (correctness checks only, nothing timed). 1. **Reading first.** The #639 issue, its comment and timeline, and its picture were read through the forge's public API; launcher #146, #175 and #176 and Longshot #1397 (the saves script's Windows default) too. The launcher was read at `a6bcd88` (the places above) and Longshot's `host/hos_main.c`, `host/nn_fs.c` and `docs/saves.md` at main `257c54911`. The picture was looked at: it shows the build's `user` folder with `save`, two `save.moved-…` and `temp`, and `Roaming\Longshot\save` holding a folder `save`. 2. **Tests first.** Commit 1 (`099183c`) adds only the new checks `GatherLink` to `tests/launcher_core/SavesChecks.cs`. Run against main's code it fails at the second of them (the first, "Taken in as before", passes on main): ``` Unhandled exception. System.Exception: saves: user\save is then a link to the shared save: a game started on its own finds the saves there. ``` (`python -I tests/test_launcher_core.py --dotnet dotnet` from the checkout, through the workbench's idle-class gate, https://github.com/mooki000/ls-workbench.) The checks for `LinkSaves`, `Leftovers` and the junction data call code that main does not have, so they cannot fail on it: they are covered by the mutations below. 3. **The whole core suite.** On this PC the suite stops at `tests/launcher_core/BuildReportChecks.cs:70` on plain main `a6bcd88` as well ("The home folder taken out before a line is cut", added by #164, whose description says Linux was not run: its line has 290 characters before the made-up Linux home folder, which the Linux rule does not take for the home folder, while the check expects `~`). Every saves check, earlier in the run, passes before it. For totals I ran main and this head in scratch copies with that one expectation skipped on Linux (`!OperatingSystem.IsWindows() ||` in front of it; nothing of it is in this branch): main `a6bcd88` 2,008 checks passed, this head 2,045 (the same suite plus this branch's checks). Without the skip both stop at that same check. The release tests (`python -I tests/test_release.py`, needs `openssl`): 37 tests OK. 4. **13 versions broken on purpose,** each in a copy of the tree (with the same skip), one rule each, and the core suite run on each; the first failing check is quoted (a mutation that only fails to compile would not count; none did): | # | One rule broken | First failing check | |---|---|---| | M1 | Gather leaves no link | "user\save is then a link to the shared save: a game started on its own finds the saves there." | | M2 | a folder with a save in it is taken aside and linked | "A folder with a save in it, a link of the player's own, and a user\ that is a link are left alone." | | M3 | a user\ that is a link is not left alone | "A folder with a save in it, a link of the player's own, and a user\ that is a link are left alone." | | M4 | any dangling link is made again, not only a portable launcher's | "A portable launcher's link whose folder moved is made again at the new place; a dangling link of the player's own is left." | | M5 | the shared save folder is not made again | "A link whose shared save folder is gone: the folder is made again, the link kept." | | M6 | no gather lock | "Another gather holds the lock: nothing is changed, nothing fails." | | M7 | links while Longshot runs | "Not while Longshot runs: the next start tries again." | | M8 | the launcher's own link is the player's own, for leftovers | "A folder with the launcher's own link to the shared save is offered; the player's own link, and mods, keep one." | | M9 | junction data: the print name's offset is wrong | "The junction's reparse data: a mount point, the target as the system and the player name it, each ended by a zero." | | M10 | a link that does not name the shared save is kept | "A link that does not name the shared save is taken away again." | | M11 | a link to nothing is not taken away on Unix | "A portable launcher's link whose folder moved is made again at the new place; a dangling link of the player's own is left." | | M12 | a folder with only options is not set aside, it is deleted | `DirectoryNotFoundException` in the check that reads the set-aside file (the folder was deleted, not set aside) | | M13 | the shared save itself may be set aside and linked | "A game folder whose user\save is the shared save itself is left alone: never set aside, never a link to itself." | 5. **A game-free reproduction of the loop** (a throwaway harness, not in the branch, attachable on request: the launcher's `Core/` compiled with a program of 70 lines; the dates are its own clock). It plays the game started on its own (a stand-in that reads `<build>\user\save\<user id>\slot_00\progress.sav`: where there is none it begins a new game, where there is one it plays on) and the launcher's starts (`Saves.OldUserFolders` and `Saves.Gather`, and on the branch `Saves.LinkSaves`) in turn, four rounds, on made-up folders of a simulated Windows environment under a temporary folder. The same program on main `a6bcd88` and on this head: main `a6bcd88`: ``` round | the game started on its own | the launcher starts: | user\ of the build holds | shared save's slots ------------------------------------------------------------------------------------------------------------------------------------------------------ 1 | finds NO save, begins a new game | takes 1 folder in, renames it save.moved-* | save.moved-20261114-201000 | slot_00="new game 20:00" 2 | finds NO save, begins a new game | takes 1 folder in, renames it save.moved-* | save.moved-20261114-201000 save.moved-20261114-204000 | slot_00="new game 20:00" slot_01="new game 20:30" 3 | finds NO save, begins a new game | takes 1 folder in, renames it save.moved-* | save.moved-20261114-201000 save.moved-20261114-204000 save.moved-20261114-211000 | slot_00="new game 20:00" slot_01="new game 20:30" slot_02="new game 21:00" 4 | finds NO save, begins a new game | takes 1 folder in, renames it save.moved-* | save.moved-20261114-201000 save.moved-20261114-204000 save.moved-20261114-211000 save.moved-20261114-214000 | slot_00="new game 20:00" slot_01="new game 20:30" slot_02="new game 21:00" slot_03="new game 21:30" ``` this head `aabeae1`: ``` round | the game started on its own | the launcher starts: | user\ of the build holds | shared save's slots ------------------------------------------------------------------------------------------------------------------------------------------------------ 1 | finds NO save, begins a new game | takes 1 folder in, renames it save.moved-* | save(link) save.moved-20261114-201000 | slot_00="new game 20:00" 2 | finds its save and plays on | takes nothing in | save(link) save.moved-20261114-201000 | slot_00="new game 20:00+" 3 | finds its save and plays on | takes nothing in | save(link) save.moved-20261114-201000 | slot_00="new game 20:00++" 4 | finds its save and plays on | takes nothing in | save(link) save.moved-20261114-201000 | slot_00="new game 20:00+++" ``` 6. **The whole solution builds:** `dotnet build LongshotLauncher.slnx --configuration Release`: 0 warnings, 0 errors (Core, App, screenshots tool). The repository's own command, with `-p:RestoreLockedMode=true`, stops with `NU1004` on this PC on plain main as well (its lock files name `Microsoft.NET.ILLink.Tasks` and `win-x64`, which SDK 10.0.113 does not resolve the same way), so the build above is without locked restore; the lock files were left as they are in the branch. 7. **Whitespace:** `git diff --check` on the branch: clean. No game file, save, key or build output is in the branch (`git status` clean; the checks make their own text-file saves). ## Not tested - **Windows, all of it.** Creating the junction (`FSCTL_SET_REPARSE_POINT` with the buffer `JunctionData` builds) on a real NTFS volume, .NET reading it back (`DirectoryInfo.LinkTarget`, `ResolveLinkTarget`) and the game started on its own with a junction as `user\save`: saving, loading, the game's atomic writes through it. The Windows-specific code is compiled here (the solution builds) and its buffer is checked byte for byte, but never run. - Disks with no junctions (FAT, exFAT, a share) and a game folder in OneDrive or Dropbox; a profile folder on a share; ReFS. - A real launcher upgrade from rc.3 and rc.4 folders; the 2.x Builder's folder. - Steam, a taskbar pin and Explorer starts of a real game (the harness stands in for the game). ## Risks - A junction made wrong would send a game's saves to the wrong folder: `MakeLink` reads it back and takes it away again unless it names the shared save, and that check is tested with a link made to another folder. A link that cannot be made leaves what a gather left before this change. - A junction in a game folder is new to every Windows player who takes this update. Deleting such a folder should remove the junction and not what it names, in the launcher (its delete never follows a link, checked on Linux with the link of this branch and #176's own check), and in Explorer or with `rd /s` (Windows' own tools: not tried here); no junction was deleted on Windows. - `LinkSaves` writes in every build's folder when the window opens: one junction per build the first time, a few `stat` calls after. - With player profiles (#55) a build's link names the shared save of the player selected when it was made; another player's Play leaves it (it is not "the shared save" of that one). A game started on its own then uses the first player's saves. - The link is the launcher's, so deleting `%APPDATA%\Longshot\save` by hand leaves it naming nothing until the next start remakes the folder. ## Overlaps The 8 open launcher pull requests were listed and their files read (`pulls/N/files`); each of the 7 that share a file with this one (#49, #50, #55, #59, #151, #183, #189) was fetched at its current head and trial-merged (`git merge-tree --write-tree`) against main `a6bcd88` and against this branch, and the conflicting files and the conflict hunks of the shared files were compared for both, since only a conflict that appears with this branch counts. Six of them (#50, #55, #59, #151, #183, #189) conflict with main already, in the same files and hunks with or without this branch (their bases are older than main); #49 merges cleanly with both. One extra hunk appears with this branch: **#55**, in `App/LauncherService.cs`, `PlayFolder` (this branch's `LinkSaves` line next to #55's `UserFolderOf(folder)`); keeping both resolves it. ## Questions for you 1. Should the game also default `--user` to the launcher's shared folder for a game folder the launcher made (a key in `longshot_version.txt`)? That would need no junction for builds made after it, and would not help the builds that exist now (nightly 170 and every rc built so far), which is why this fixes it in the launcher first. 2. Should the home say once that a build now shares its saves through a link? It says nothing today (no new text, no catalog change); the notice of #175 still appears when a gather took something in. 3. A portable launcher's link names the portable folder's absolute path and is made again when the folder moves (the start after the move). Is that acceptable, or should a portable launcher get no link? New on this forge; not opened on GitHub.
On Windows a build started on its own (no --user) keeps its saves in its own
folder's user\save. The launcher's start takes them into the shared folder and
renames that folder aside, so that game finds no save, begins a new one there,
and the next start moves it again.

These checks say what should happen instead: after the gather, user\save is a
link to the shared save, so the game started on its own reads and writes the
shared saves, and the launcher's next starts find nothing to take in and move
nothing. Another check keeps what a gather left before when no link can be made
(a drive with no junctions): taken in, renamed aside, no failure.

They fail on main at "user\save is then a link to the shared save".

Assisted-by: Claude Sonnet 5.5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
fix(saves): a build started on its own reads the shared saves through a link, so the launcher stops moving its folder (Longshot#639)
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 5s
aabeae1bdd
On Windows the launcher starts every build with --user %APPDATA%\Longshot, but a
build started any other way (bin\longshot.exe in Explorer, a taskbar pin, Steam,
an old Builder's shortcut) has no --user, and the game keeps its saves in its own
folder's user\save. Saves.Gather, which runs when the launcher opens and before
every Play, took that folder into the shared one and renamed it save.moved-<stamp>.
The game started on its own then found no save, began a new one in the same
place, and the next start of the launcher moved that too: every start moved the
folder, and the game "thought there were no saves".

Where Gather renames a save aside it now makes user\save a link to the shared save
(a junction on Windows, FileLinks.TryDirectoryLink), so the game started on its own
reads and writes the shared saves, and there is nothing to take in at the next
start. Saves.LinkSaves makes the same link in a game folder that has no user\save,
or one with only the game's own options (set aside first, nothing deleted), when the
launcher opens and before Play, and makes a portable launcher's link again when its
folder moved. It leaves a user\ or user\save that is a link of the player's, a folder
with a save in it (Gather's to take in) and the shared save itself alone, does
nothing while Longshot runs or another launcher holds the gather lock, and never
fails: a link that cannot be made leaves the folder as it was before.

Leftovers counts the launcher's own link as nothing of the player's, so the old
versions it offers to delete are offered as before. docs/saves.md and README.md say
how a build started on its own now behaves.

The merge checks of #175 simulate a build that puts a plain user\save in again after
each start; they run with the link switched off (a disk with no junctions), as
before. The checks for the link are new.

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

Possibly related, for context:

  • issue MagicBeanDev/Longshot#639 Saves: Every time I launch the game, the save folder gets moved and the game thinks there is no saves and I have to move it back — Directly fixes repeated save-folder moves
  • issue MagicBeanDev/Longshot#760 Idea: Make direct game launches use shared saves on Windows — Direct-launch shared-saves request
Possibly related, for context: - issue MagicBeanDev/Longshot#639 Saves: Every time I launch the game, the save folder gets moved and the game thinks there is no saves and I have to move it back — Directly fixes repeated save-folder moves - issue MagicBeanDev/Longshot#760 Idea: Make direct game launches use shared saves on Windows — Direct-launch shared-saves request
HumanBean deleted branch fix/saves-shared-link 2026-11-18 02:31:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/LongshotLauncher!196
No description provided.