fix(saves): a build started on its own reads the shared saves through a link, so the launcher stops moving its folder #196
No reviewers
Labels
No labels
area/build
area/install
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!196
Loading…
Reference in a new issue
No description provided.
Delete branch "mooki/LongshotLauncher:fix/saves-shared-link"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 tosave.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
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.--user <shared folder>, a game started on its own has no--userand saves in<game folder>\user\save.Saves.Gatherruns when the launcher opens and before every Play and treats every build'suser\saveas an old save: it merges it into the shared one and renames itsave.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.Gatherrenames a save aside it leaves a link to the shared save (a junction on Windows) atuser\save;Saves.LinkSavesmakes the same link in a game folder that has nouser\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.Gather(#175) and of Delete (#176); auser\oruser\savethat 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.--userfor a folder the launcher made (Questions).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-083238after opening the launcher, and the saves intact inLongshotLauncher-data\user\save\<user id>. The chain, at launchera6bcd88and Longshot main257c54911(the lines quoted are at those commits;host/hos_main.cmoved four lines since I first read it, and what it does here did not change):--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: "Startinglongshot.exedirectly without--userdoes not use the launcher's shared save folder" (docs/saves.md:110).--useronly when it starts the game:Core/MakeGameCommand.cs:240-242(UserFolder:%APPDATA%\Longshot, a portable launcher'sLongshotLauncher-data\user),:260-264, fromApp/LauncherService.cs:252-273(PlayFolder: Play, the Ready screen, the shortcut's--play).App/App.axaml.cs:52(the window opens) andApp/LauncherService.cs:254(before every Play) callGatherSaves()(:344-356), which runsSaves.GatheroverSaves.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 renamedsave.moved-<stamp>(:843-848).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.userfolder holdstemp,save(8:48 PM) and twosave.moved-…(stamps 20:04:39 and 20:15:59, their contents last written 7:41 PM and 8:06 PM).user\tempanduser\saveappear 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--userand two launcher starts that moved their saves. (Inferred: the folder namedsaveinsideRoaming\Longshot\savein 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.)OldUserFolderscompares without case,Gatheralso compares resolved paths); a tie keeps the shared save; a portable and an installed launcher have separatebuilds.jsonand 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.exein its folder and save; open the launcher (or press Play in it); startbin\longshot.exeagainExpected: the game finds the save it made
Actual: it finds none;
user\save.moved-<yyyyMMdd-HHmmss>has appeared beside a newuser\save; each further launcher start moves the new one tooWhat changed
Core/Saves.cs:Gathermakes a link to the shared save at theuser\saveit renamed aside (MakeLink, which reads the link back and takes it away again unless it names the shared save and can be read). NewLinkSaves(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 (nouser\save), aside then make (a folder with no save in it, only the game's options: renamedsave.moved-<stamp>, nothing deleted), empty (an empty folder replaced), repoint (a portable launcher's link whose folder moved, recognised byLongshotLauncher-data\user\saveat the end of what it names and by naming nothing). Left alone: auser\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.LinksToSharedsays 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 throughFSCTL_SET_REPARSE_POINTon Windows, which needs no privilege; a symbolic link elsewhere or where the junction fails; nothing left behind when none is made) andJunctionData(the reparse buffer, a pure function with its own check).Core/Leftovers.cs,App/LauncherService.cs:Leftovers.Findtakes 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;GatherSaveslinks every build's folder after the gather, andPlayFolderthe folder it starts.docs/saves.md,README.md: how a build started on its own behaves now.tests/launcher_core/SavesChecks.cs(GatherLink,LinkSavesChecks; the merge checks of #175 run with the link switched off, because they put a plainuser\savein again after each start, as a disk with no junctions would),LeftoverChecks.cs.Unchanged on purpose: Linux and the Steam Deck; what
Gathermerges, 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.jsonwas changed locally for the runs and is not in the branch), 17 Nov 2026, basea6bcd88(launcher main), headaabeae1, load average 20 to 47 from other jobs on the PC (correctness checks only, nothing timed).a6bcd88(the places above) and Longshot'shost/hos_main.c,host/nn_fs.canddocs/saves.mdat main257c54911. The picture was looked at: it shows the build'suserfolder withsave, twosave.moved-…andtemp, andRoaming\Longshot\saveholding a foldersave.099183c) adds only the new checksGatherLinktotests/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): (python -I tests/test_launcher_core.py --dotnet dotnetfrom the checkout, through the workbench's idle-class gate, https://github.com/mooki000/ls-workbench.) The checks forLinkSaves,Leftoversand the junction data call code that main does not have, so they cannot fail on it: they are covered by the mutations below.tests/launcher_core/BuildReportChecks.cs:70on plain maina6bcd88as 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): maina6bcd882,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, needsopenssl): 37 tests OK.DirectoryNotFoundExceptionin the check that reads the set-aside file (the folder was deleted, not set aside)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.OldUserFoldersandSaves.Gather, and on the branchSaves.LinkSaves) in turn, four rounds, on made-up folders of a simulated Windows environment under a temporary folder. The same program on maina6bcd88and on this head:main
a6bcd88:this head
aabeae1: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 withNU1004on this PC on plain main as well (its lock files nameMicrosoft.NET.ILLink.Tasksandwin-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.Whitespace:
git diff --checkon the branch: clean. No game file, save, key or build output is in the branch (git statusclean; the checks make their own text-file saves).Not tested
FSCTL_SET_REPARSE_POINTwith the bufferJunctionDatabuilds) on a real NTFS volume, .NET reading it back (DirectoryInfo.LinkTarget,ResolveLinkTarget) and the game started on its own with a junction asuser\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.Risks
MakeLinkreads 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.rd /s(Windows' own tools: not tried here); no junction was deleted on Windows.LinkSaveswrites in every build's folder when the window opens: one junction per build the first time, a fewstatcalls after.%APPDATA%\Longshot\saveby 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 maina6bcd88and 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, inApp/LauncherService.cs,PlayFolder(this branch'sLinkSavesline next to #55'sUserFolderOf(folder)); keeping both resolves it.Questions for you
--userto the launcher's shared folder for a game folder the launcher made (a key inlongshot_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.New on this forge; not opened on GitHub.
Possibly related, for context:
madebyjordan referenced this pull request2026-11-18 21:11:50 +00:00
omgitsgela referenced this pull request2026-11-21 11:57:36 +00:00