WIP: fix(update): an update built from its own folder's game files reads them after the folder is renamed #248

Draft
dyst wants to merge 2 commits from dyst/LongshotLauncher:fix/update-rename-paths into main
Member

An update built from the game files in the version's own folder (its romfs and .longshot_exefs) always fails. The build step renames the folder to the new version's name and then gives make_game.py the old folder's paths, which no longer exist, so every retry fails the same way (Longshot#2142, #240). #207 was meant to fix this: it moves job.Picked to the new paths, but Run() had already read job.Picked by then. That is why #2142's log shows "game files: in the renamed folder, read from …" and still fails.

Based on #246 (main's CI fix), so its first commit is that one until #246 merges.

Summary

  • App/ViewModels/BuildStepViewModel.cs: the request make_game.py gets is made in a new Request(), which renames the folder first and only then reads the game files. Run() calls it; nothing else in Run() changed.
  • tests/launcher_app/Program.cs: UpdateFromOwnFolder makes a fake instance in builds/nightly/nightly-100-… with its own romfs and .longshot_exefs (text files, no game data). It updates it to nightly-101-… through BuildJob and BuildStepViewModel.Request(), and requires the request to name the renamed folder's files and to build into that folder.

Read first: BuildStepViewModel.Request().

Testing

Tested (Windows 11, .NET SDK 10.0.404):

  • tests/launcher_app builds and passes.
  • With the old order put back (the files read before the rename), it fails with the old folder's romfs path, as #2142 reports.

Still to test:

  • An update in the launcher from a version's own folder (nightly to nightly) by hand: not run here, since that is a full game build. The #2142 reporter's case is the one to confirm.

Risks

Low. The only change in order is that the rename now happens before the game files are read. A refused rename still fails the build before anything starts, with the same message.

πŸ€– Generated with Claude Code

An update built from the game files in the version's own folder (its `romfs` and `.longshot_exefs`) always fails. The build step renames the folder to the new version's name and then gives make_game.py the old folder's paths, which no longer exist, so every retry fails the same way ([Longshot#2142](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/2142), [#240](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/issues/240)). #207 was meant to fix this: it moves `job.Picked` to the new paths, but `Run()` had already read `job.Picked` by then. That is why #2142's log shows "game files: in the renamed folder, read from …" and still fails. Based on #246 (main's CI fix), so its first commit is that one until #246 merges. ## Summary - `App/ViewModels/BuildStepViewModel.cs`: the request make_game.py gets is made in a new `Request()`, which renames the folder first and only then reads the game files. `Run()` calls it; nothing else in `Run()` changed. - `tests/launcher_app/Program.cs`: `UpdateFromOwnFolder` makes a fake instance in `builds/nightly/nightly-100-…` with its own `romfs` and `.longshot_exefs` (text files, no game data). It updates it to `nightly-101-…` through `BuildJob` and `BuildStepViewModel.Request()`, and requires the request to name the renamed folder's files and to build into that folder. Read first: `BuildStepViewModel.Request()`. ## Testing **Tested** (Windows 11, .NET SDK 10.0.404): - `tests/launcher_app` builds and passes. - With the old order put back (the files read before the rename), it fails with the old folder's `romfs` path, as #2142 reports. **Still to test:** - An update in the launcher from a version's own folder (nightly to nightly) by hand: not run here, since that is a full game build. The #2142 reporter's case is the one to confirm. ## Risks Low. The only change in order is that the rename now happens before the game files are read. A refused rename still fails the build before anything starts, with the same message. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
fix(update): an update built from its own folder's game files reads them after the folder is renamed
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 12s
f9fb7bda2d
The build step read the picked game files before RenameFolder renamed an update's folder to its new version's name, so
make_game.py was given the old folder's romfs and .longshot_exefs, which no longer exist, and every retry failed the same
way. #207 moved job.Picked to the new paths, but after Run() had already read it. The request is now made after the
rename (BuildStepViewModel.Request), and the app checks drive a real rename through it: they fail with the old order.

Fixes LongshotLauncher#240 and Longshot#2142.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dyst force-pushed fix/update-rename-paths from f9fb7bda2d
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 12s
to 552702457d
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
2026-11-21 23:44:50 +00:00
Compare
Contributor

A red-first source check for #2142's order (tests/launcher_core)

tests/launcher_app's UpdateFromOwnFolder is a good behavioural test, but it can't be this PR's red-first test: it calls Request(), which doesn't exist on main. A source-order check can run on both heads β€” it fails on main today, for the bug's reason, and passes here.

Where: tests/launcher_core/InstanceFolderChecks.cs, inserted before static void InstanceFolderChecks() (line 93), and one call in tests/launcher_core/Program.cs after InstanceFolderChecks().

    /// The update's request in its source: BuildStepViewModel renames the folder to the new version's name before it reads the
    /// game files the request is made from (job.Picked). Read first, the request named the old folder's paths, which the rename
    /// had just moved, and every retry failed the same way (LongshotLauncher#240, Longshot#2142). The order, from the source: the
    /// launcher_app test that builds the request runs the real thing, where this reads the code it is built in
    static void UpdateRequestSourceChecks(string repo)
    {
        var build = File.ReadAllText(Path.Combine(repo, "App", "ViewModels", "BuildStepViewModel.cs"));
        int At(string code) => build.IndexOf(code, StringComparison.Ordinal);
        int Line(int at) => at < 0 ? 0 : build.AsSpan(0, at).Count('\n') + 1;
        var rename = At("if (!RenameFolder())");
        var read = At("var file = job.Picked!");
        var request = At("new BuildRequest(file.Source");
        Require(rename >= 0 && read >= 0 && request > read && rename < read,
                $"The build reads its game files after the update's folder is renamed (found RenameFolder() on line {Line(rename)}, job.Picked on line {Line(read)}).");
    }
        InstanceFolderChecks();
        UpdateRequestSourceChecks(Path.GetFullPath(Path.Combine(fixtures, "..", "..")));

On main it fails (App/ViewModels/BuildStepViewModel.cs, Run()):

The build reads its game files after the update's folder is renamed (found RenameFolder() on line 177, job.Picked on line 175).

var file = job.Picked! is at :175 and if (!RenameFolder()) return; at :177 β€” the read is the stale one. On this PR: the rename is :180, the read :181, and new BuildRequest(file.Source, …) :187, so it passes.

Why not the literal regex. Regex.IsMatch(build, @"RenameFolder\(\)[\s\S]*?var file = job\.Picked!") is green on main as written: over the whole file the non-greedy span starts at the rename (:177) and runs to Complete()'s own var file = job.Picked! at :619. It never sees the order. Scoped to the Run() body it would be red, but it can't also be green here, where that body moved to Request(). The index form anchors on the rename call and on the first read before the BuildRequest it feeds, so Complete()'s later read can't satisfy it, and neither can a comment that mentions RenameFolder().

Why it matters: this is the regression #207 missed β€” the rename and the read were both there, only in the wrong order. A text check is the only form that is red on main; it keeps a later refactor of Request()/Run() from flipping the order back.

The patch applies cleanly to both main and this PR's head 5527024. I haven't pushed it to your branch β€” take it as your own commit if you want it (the three strings are the only thing to adjust if you rename the local).

Not run here (no build slot on this PC): the red/green above is from the exact IndexOf positions in each head's BuildStepViewModel.cs, not from a test run.

β€” dazemc

### A red-first source check for #2142's order (`tests/launcher_core`) `tests/launcher_app`'s `UpdateFromOwnFolder` is a good behavioural test, but it can't be this PR's red-first test: it calls `Request()`, which doesn't exist on `main`. A source-order check can run on both heads β€” it fails on `main` today, for the bug's reason, and passes here. **Where:** `tests/launcher_core/InstanceFolderChecks.cs`, inserted before `static void InstanceFolderChecks()` (line 93), and one call in `tests/launcher_core/Program.cs` after `InstanceFolderChecks()`. ```csharp /// The update's request in its source: BuildStepViewModel renames the folder to the new version's name before it reads the /// game files the request is made from (job.Picked). Read first, the request named the old folder's paths, which the rename /// had just moved, and every retry failed the same way (LongshotLauncher#240, Longshot#2142). The order, from the source: the /// launcher_app test that builds the request runs the real thing, where this reads the code it is built in static void UpdateRequestSourceChecks(string repo) { var build = File.ReadAllText(Path.Combine(repo, "App", "ViewModels", "BuildStepViewModel.cs")); int At(string code) => build.IndexOf(code, StringComparison.Ordinal); int Line(int at) => at < 0 ? 0 : build.AsSpan(0, at).Count('\n') + 1; var rename = At("if (!RenameFolder())"); var read = At("var file = job.Picked!"); var request = At("new BuildRequest(file.Source"); Require(rename >= 0 && read >= 0 && request > read && rename < read, $"The build reads its game files after the update's folder is renamed (found RenameFolder() on line {Line(rename)}, job.Picked on line {Line(read)})."); } ``` ```csharp InstanceFolderChecks(); UpdateRequestSourceChecks(Path.GetFullPath(Path.Combine(fixtures, "..", ".."))); ``` **On `main` it fails** (`App/ViewModels/BuildStepViewModel.cs`, `Run()`): ```text The build reads its game files after the update's folder is renamed (found RenameFolder() on line 177, job.Picked on line 175). ``` `var file = job.Picked!` is at `:175` and `if (!RenameFolder()) return;` at `:177` β€” the read is the stale one. On this PR: the rename is `:180`, the read `:181`, and `new BuildRequest(file.Source, …)` `:187`, so it passes. **Why not the literal regex.** `Regex.IsMatch(build, @"RenameFolder\(\)[\s\S]*?var file = job\.Picked!")` is green on `main` as written: over the whole file the non-greedy span starts at the rename (`:177`) and runs to `Complete()`'s own `var file = job.Picked!` at `:619`. It never sees the order. Scoped to the `Run()` body it would be red, but it can't also be green here, where that body moved to `Request()`. The index form anchors on the rename call and on the first read before the `BuildRequest` it feeds, so `Complete()`'s later read can't satisfy it, and neither can a comment that mentions `RenameFolder()`. **Why it matters:** this is the regression #207 missed β€” the rename and the read were both there, only in the wrong order. A text check is the only form that is red on `main`; it keeps a later refactor of `Request()`/`Run()` from flipping the order back. The patch applies cleanly to both `main` and this PR's head `5527024`. I haven't pushed it to your branch β€” take it as your own commit if you want it (the three strings are the only thing to adjust if you rename the local). Not run here (no build slot on this PC): the red/green above is from the exact `IndexOf` positions in each head's `BuildStepViewModel.cs`, not from a test run. β€” dazemc
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/update-rename-paths:dyst-fix/update-rename-paths'
git switch 'dyst-fix/update-rename-paths'
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!248
No description provided.