fix(profiles): take the profile's edit lock as Longshot's builder does, so installs and updates finish again #427

Merged
HumanBean merged 3 commits from llun/LongshotLauncher:fix/profile-edit-lock-os-lock into main 2026-12-05 21:02:48 +00:00
Member

Since Longshot nightly-1179, every install and update in the Launcher stops at its last step with "Another editor is changing this profile. Try again in a moment.", and trying again stops the same way (#426). The Launcher now takes the profile's edit lock the way Longshot's builder does.

Why it happens

The Launcher, Longshot's builder and the mod tools share one lock file per profile, .longshot-edit.lock. Longshot #3020 (merged 2026-12-05, first in nightly-1179) changed the builder's side to an operating-system lock on that file (File::try_lock), and the file now stays in place, empty, once the lock is let go. Every longshot-builder build --profile takes it, since play::ensure_built first writes copied mods into the profile (modtool::record_mods).

The Launcher took any existing file as held, and only moved one aside when its second word was a time more than 30 seconds old. An empty file has none, so after each build remember_build_options (src/game/wizard.rs) waited 2 seconds and failed. By then the build was in place and the version registered, but the build options, the game language, the settings and the clean-up of old builder downloads were skipped. Any other Launcher edit of that profile (save names, mods, language) failed the same way while the file was there, and every Play made it again.

What changes

  • src/players/profiles.rs: the edit lock opens .longshot-edit.lock (made when missing, never emptied), try_locks it for up to 2 seconds as before, and leaves the file in place: the same rule as the builder's launcher-profile and the mod tools. A file nobody holds never keeps an edit out, and a holder that ends however it ends lets go with its process, so the time stamp, the 30-second rule and the moving aside are gone.
  • Builders from before nightly-1179 still work with it. They hold the lock the old way: the file made with <pid> <epoch seconds> in it, free again when it is gone, unreadable or over 30 seconds old. While the Launcher holds the OS lock the file carries that text too, and it is emptied before the lock is let go, so an old builder waits for the Launcher's edit and finds the file free after it (on Windows it can't even read a locked file, so it waits either way). A fresh text of that form keeps the Launcher waiting in turn. Where an old builder could move the file aside as stale between the Launcher's lock and its text (not on Windows), the Launcher checks the path still names its file and takes it again if not. The 1179 builder ignores the text.
  • The error text is unchanged.

Tested

  • Game-free tests that fail on main for the bug's reason (first commit): a_lock_file_the_builder_left_does_not_keep_an_edit_out (the file as the builder leaves it, made and locked with the builder's own OpenOptions and try_lock) and an_edit_waits_for_the_builder_while_it_holds_the_lock (an edit waits and fails while the builder holds it, goes through once it lets go, and the builder can take it again). Both fail on main with "Another editor is changing this profile" and pass with the fix.
  • Builders from before nightly-1179 (third commit, after review): a_lock_an_old_builder_holds_keeps_an_edit_out_until_it_is_stale (a fresh <pid> <time> keeps the edit out; one 60 s old, or one ahead of the clock, doesn't, and the file is empty after) and an_old_builder_waits_while_the_launcher_edits_and_finds_the_lock_free_after (during the edit the file can't be read on Windows and holds this process's id and the time elsewhere; after it the file is empty, which an old builder takes as free, and the 1179 builder takes the lock again).
  • Windows 11, gnullvm toolchain: cargo clippy --locked --all-targets -- -D warnings clean, rustfmt clean, python -I tests/test_launcher_core.py (353 passed, 0 failed, 5 ignored), Tooling's tests/test_release.py (46 tests, OK).
  • Linux (Ubuntu 24.04 in WSL 2, Rust 1.99.1): the players tests (25 passed, the four lock tests among them, on flock and the path check) and cargo clippy --locked --all-targets -- -D warnings clean.
  • In the Launcher on Windows 11, a scratch portable library, the real nightly-1179 builder and game file, no shader preparation:
    • Main's Launcher, a fresh install of nightly-1179: the build finished (224 s), then "Registering the installation" and, 2 s later, "Another editor is changing this profile". The profile's .longshot-edit.lock was there, 0 bytes.
    • The version relabelled as nightly-1158 in its record so the Launcher offers "Update to nightly-1179", main's Launcher, Update: fast check: current, seconds: 0.0, "Registering the installation", then the same error 2 s later: the player's log line for line.
    • The same library and update with this branch: fast check: current, "Registering the installation", "Checking unused builder downloads", "Build completed" 0.2 s later; the profile now names nightly-1179 and its game file, and the builder's empty lock file is still in place.
    • Screenshots in the comments.
    • Again with the third commit, in a new scratch library: a fresh install of nightly-1179 (173 s build, then "Build completed" 0.1 s after "Registering the installation") and the update as above (fast check: current, "Build completed" 0.2 s after). Both times the lock file was left in place and empty.
  • Not run by hand: a Play or a game run (the change is only the Launcher's edit lock, which Play takes only for its profile edits).

Not covered

  • The 1179 builder itself doesn't wait for an old builder's text (Longshot #3020): two versions' builders editing one profile in the same moment is between them, not the Launcher.
  • One window with an old builder stays on Linux: an old builder that read the file as free just before the Launcher locked it, and moves it aside only after the Launcher's path check, edits beside it. Nothing in the file can stop another process's rename there; it is the old protocol's own race (between two old builders too, and between an old builder and the 1179 builder), and it needs a game from before nightly-1179 running on that profile and a Launcher edit in the same instant. Closing it would mean changing the old builders.
  • A Linux install or update in the Launcher with the real nightly-1179 builder: the tests above ran on Linux, but not the Launcher itself with the builder (this PC has no Linux desktop). Asked of the Test Farm in the comments.

🤖 Generated with Claude Code

Since Longshot nightly-1179, every install and update in the Launcher stops at its last step with "Another editor is changing this profile. Try again in a moment.", and trying again stops the same way ([#426](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/issues/426)). The Launcher now takes the profile's edit lock the way Longshot's builder does. ## Why it happens The Launcher, Longshot's builder and the mod tools share one lock file per profile, `.longshot-edit.lock`. Longshot [#3020](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3020) (merged 2026-12-05, first in nightly-1179) changed the builder's side to an operating-system lock on that file (`File::try_lock`), and the file now stays in place, empty, once the lock is let go. Every `longshot-builder build --profile` takes it, since `play::ensure_built` first writes copied mods into the profile (`modtool::record_mods`). The Launcher took any existing file as held, and only moved one aside when its second word was a time more than 30 seconds old. An empty file has none, so after each build `remember_build_options` (`src/game/wizard.rs`) waited 2 seconds and failed. By then the build was in place and the version registered, but the build options, the game language, the settings and the clean-up of old builder downloads were skipped. Any other Launcher edit of that profile (save names, mods, language) failed the same way while the file was there, and every Play made it again. ## What changes - `src/players/profiles.rs`: the edit lock opens `.longshot-edit.lock` (made when missing, never emptied), `try_lock`s it for up to 2 seconds as before, and leaves the file in place: the same rule as the builder's `launcher-profile` and the mod tools. A file nobody holds never keeps an edit out, and a holder that ends however it ends lets go with its process, so the time stamp, the 30-second rule and the moving aside are gone. - **Builders from before nightly-1179 still work with it.** They hold the lock the old way: the file made with `<pid> <epoch seconds>` in it, free again when it is gone, unreadable or over 30 seconds old. While the Launcher holds the OS lock the file carries that text too, and it is emptied before the lock is let go, so an old builder waits for the Launcher's edit and finds the file free after it (on Windows it can't even read a locked file, so it waits either way). A fresh text of that form keeps the Launcher waiting in turn. Where an old builder could move the file aside as stale between the Launcher's lock and its text (not on Windows), the Launcher checks the path still names its file and takes it again if not. The 1179 builder ignores the text. - The error text is unchanged. ## Tested - **Game-free tests that fail on main for the bug's reason** (first commit): `a_lock_file_the_builder_left_does_not_keep_an_edit_out` (the file as the builder leaves it, made and locked with the builder's own `OpenOptions` and `try_lock`) and `an_edit_waits_for_the_builder_while_it_holds_the_lock` (an edit waits and fails while the builder holds it, goes through once it lets go, and the builder can take it again). Both fail on main with "Another editor is changing this profile" and pass with the fix. - **Builders from before nightly-1179** (third commit, after review): `a_lock_an_old_builder_holds_keeps_an_edit_out_until_it_is_stale` (a fresh `<pid> <time>` keeps the edit out; one 60 s old, or one ahead of the clock, doesn't, and the file is empty after) and `an_old_builder_waits_while_the_launcher_edits_and_finds_the_lock_free_after` (during the edit the file can't be read on Windows and holds this process's id and the time elsewhere; after it the file is empty, which an old builder takes as free, and the 1179 builder takes the lock again). - Windows 11, gnullvm toolchain: `cargo clippy --locked --all-targets -- -D warnings` clean, rustfmt clean, `python -I tests/test_launcher_core.py` (353 passed, 0 failed, 5 ignored), Tooling's `tests/test_release.py` (46 tests, OK). - Linux (Ubuntu 24.04 in WSL 2, Rust 1.99.1): the players tests (25 passed, the four lock tests among them, on `flock` and the path check) and `cargo clippy --locked --all-targets -- -D warnings` clean. - **In the Launcher on Windows 11**, a scratch portable library, the real nightly-1179 builder and game file, no shader preparation: - Main's Launcher, a fresh install of nightly-1179: the build finished (224 s), then "Registering the installation" and, 2 s later, "Another editor is changing this profile". The profile's `.longshot-edit.lock` was there, 0 bytes. - The version relabelled as nightly-1158 in its record so the Launcher offers "Update to nightly-1179", main's Launcher, **Update**: `fast check: current`, `seconds: 0.0`, "Registering the installation", then the same error 2 s later: the player's log line for line. - The same library and update with this branch: `fast check: current`, "Registering the installation", "Checking unused builder downloads", "Build completed" 0.2 s later; the profile now names nightly-1179 and its game file, and the builder's empty lock file is still in place. - Screenshots in the comments. - Again with the third commit, in a new scratch library: a **fresh install** of nightly-1179 (173 s build, then "Build completed" 0.1 s after "Registering the installation") and the **update** as above (`fast check: current`, "Build completed" 0.2 s after). Both times the lock file was left in place and empty. - Not run by hand: a Play or a game run (the change is only the Launcher's edit lock, which Play takes only for its profile edits). ## Not covered - The 1179 builder itself doesn't wait for an old builder's text (Longshot #3020): two versions' builders editing one profile in the same moment is between them, not the Launcher. - One window with an old builder stays on Linux: an old builder that read the file as free just before the Launcher locked it, and moves it aside only after the Launcher's path check, edits beside it. Nothing in the file can stop another process's rename there; it is the old protocol's own race (between two old builders too, and between an old builder and the 1179 builder), and it needs a game from before nightly-1179 running on that profile and a Launcher edit in the same instant. Closing it would mean changing the old builders. - A Linux install or update in the Launcher with the real nightly-1179 builder: the tests above ran on Linux, but not the Launcher itself with the builder (this PC has no Linux desktop). Asked of the Test Farm in the comments. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Longshot's builder locks .longshot-edit.lock through the operating system since
Longshot #3020 and leaves the file in place, empty. Both tests fail on main with
"Another editor is changing this profile": the launcher takes any existing
file as held.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(profiles): take the profile's edit lock as Longshot's builder does, an OS lock on a file that stays (#426)
Some checks failed
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Has been cancelled
CI / Rust formatting, lint and tests (pull_request) Has been cancelled
CI / Release packages and stable upgrades (pull_request) Has been cancelled
PR title / Conventional Commit title (pull_request) Has been cancelled
47f688fe8f
Since Longshot #3020 (first in nightly-1179) the builder locks
.longshot-edit.lock through the operating system and leaves the file in
place, empty. The launcher took any existing file as held and only moved
aside one with a time over 30 seconds old, so after every build it waited
2 seconds and stopped with "Another editor is changing this profile":
each install and update failed at Registering the installation.

The launcher now opens the file (made when missing), try_locks it for up to
2 seconds and leaves it in place, as the builder and the mod tools do. A file
nobody holds never keeps an edit out; a holder that ends however it ends
lets go of the lock with its process.

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

The hand test in a scratch portable library (Windows 11, real nightly-1179 builder):

Main's Launcher, fresh install of nightly-1179: the build finished, then the error.
main: install stopped

Main's Launcher, update to nightly-1179 (fast check: current, seconds: 0.0, as in the player's log):
main: update stopped

This branch, the same update: finished, "Build completed".
this branch: update done

The hand test in a scratch portable library (Windows 11, real nightly-1179 builder): **Main's Launcher, fresh install of nightly-1179:** the build finished, then the error. ![main: install stopped](https://git.magicbean.dev/attachments/a164100a-28bb-423b-b838-2f3ed4aefb7f) **Main's Launcher, update to nightly-1179** (`fast check: current`, `seconds: 0.0`, as in the player's log): ![main: update stopped](https://git.magicbean.dev/attachments/5e6be503-c864-46b1-a625-5ebb29785469) **This branch, the same update:** finished, "Build completed". ![this branch: update done](https://git.magicbean.dev/attachments/c5304ce2-61c9-4d68-a3a8-c75299f832f0)
llun changed title from WIP: fix(profiles): take the profile's edit lock as Longshot's builder does, so installs and updates finish again to fix(profiles): take the profile's edit lock as Longshot's builder does, so installs and updates finish again 2026-12-05 20:29:43 +00:00
BeanBot requested changes 2026-12-05 20:31:14 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The recorded Windows update shows that the new lock fixes the nightly-1179 failure, but it breaks profile edits by older installed builders and no longer excludes their concurrent edits. Linux interoperability has not yet been exercised.

The launcher uses the builder’s operating-system lock, allowing installs and updates to finish when an empty lock file remains. The cost is a compatibility regression for profiles still used by pre-nightly-1179 games.

Blocking (1): must change before merging.

  1. L1 src/players/profiles.rs:106: The new lock protocol is incompatible with installed builders that still use the existence of this file as their lock. (more on the line) Do: Provide a safe transition for profiles used by older builders, coordinating with both lock protocols or preventing incompatible versions from using the profile until they are updated. Cover both an old holder and an old builder starting after a launcher edit.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 src/players/profiles.rs:110: The changed platform locking path has not been exercised on Linux with the actual builder. (more on the line) Do: Run a Linux install or update with the nightly-1179 builder and check contention and release between the builder and launcher.

@fix can do L1.

Checks: Still running: 5 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes for the reported Windows update: the author reports that main failed after a two-second wait, while this branch completed the same update in 0.2 seconds. A fresh install with this branch and Linux have not been run by hand.

Other systems: The lock is shared by profile edits, mod operations, language changes and builders on Windows and Linux. New builders use the same OS-lock protocol; older builders use file existence and are incompatible with the new behavior. Linux uses the intended flock mechanism but has no recorded run.

Switches: None.

Reviewed: 47f688fe8f against 48e2d127a6: Read AGENTS.md, CONTRIBUTING.md, the commit messages and both changed files; traced FileLease and profile-edit callers, including build registration, language and mod edits. Read docs/pull-requests.md. The named review checklist and pull request template are absent. Screenshots were not accessible; their accompanying run descriptions were read. No generated files or translations changed.; nothing run (a code review).

Checked and fine:

  • Both commits have AI co-author trailers, and the changed test fixtures are synthetic.
  • The new tests cover an unheld builder lock file and contention while the builder holds the lock.
  • FileLease releases the OS lock on scope exit, including error returns.

Testing: Read-only review; no code or tests were run. The author reports Windows clippy, formatting, core and release tests passing, plus the recorded Windows update run. CI is still running.

Overlaps and merge order: None found in the supplied review context.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as llun took it out of WIP. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The recorded Windows update shows that the new lock fixes the nightly-1179 failure, but it breaks profile edits by older installed builders and no longer excludes their concurrent edits. Linux interoperability has not yet been exercised. The launcher uses the builder’s operating-system lock, allowing installs and updates to finish when an empty lock file remains. The cost is a compatibility regression for profiles still used by pre-nightly-1179 games. **Blocking (1)**: must change before merging. 1. **L1** `src/players/profiles.rs:106`: The new lock protocol is incompatible with installed builders that still use the existence of this file as their lock. (more on the line) **Do:** Provide a safe transition for profiles used by older builders, coordinating with both lock protocols or preventing incompatible versions from using the profile until they are updated. Cover both an old holder and an old builder starting after a launcher edit. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `src/players/profiles.rs:110`: The changed platform locking path has not been exercised on Linux with the actual builder. (more on the line) **Do:** Run a Linux install or update with the nightly-1179 builder and check contention and release between the builder and launcher. `@fix` can do L1. **Checks:** Still running: 5 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the reported Windows update: the author reports that main failed after a two-second wait, while this branch completed the same update in 0.2 seconds. A fresh install with this branch and Linux have not been run by hand. **Other systems:** The lock is shared by profile edits, mod operations, language changes and builders on Windows and Linux. New builders use the same OS-lock protocol; older builders use file existence and are incompatible with the new behavior. Linux uses the intended flock mechanism but has no recorded run. **Switches:** None. **Reviewed:** 47f688fe8f86 against 48e2d127a688: Read AGENTS.md, CONTRIBUTING.md, the commit messages and both changed files; traced FileLease and profile-edit callers, including build registration, language and mod edits. Read docs/pull-requests.md. The named review checklist and pull request template are absent. Screenshots were not accessible; their accompanying run descriptions were read. No generated files or translations changed.; nothing run (a code review). **Checked and fine:** - Both commits have AI co-author trailers, and the changed test fixtures are synthetic. - The new tests cover an unheld builder lock file and contention while the builder holds the lock. - FileLease releases the OS lock on scope exit, including error returns. **Testing:** Read-only review; no code or tests were run. The author reports Windows clippy, formatting, core and release tests passing, plus the recorded Windows update run. CI is still running. **Overlaps and merge order:** None found in the supplied review context. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as llun took it out of WIP. Nothing was run; a maintainer decides.</sub>
@ -115,0 +103,4 @@
.truncate(false)
.read(true)
.write(true)
.open(dir.join(".longshot-edit.lock"))
Member

L1 (blocking): The new lock protocol is incompatible with installed builders that still use the existence of this file as their lock.

When: After any launcher profile edit, the empty file remains in place, so a pre-nightly-1179 builder cannot acquire its old-style lock for the game's mod prompts or switches. Conversely, if an old builder already holds its timestamped file, the launcher takes an OS lock on it anyway, allowing concurrent profile edits and potentially lost changes.

Do: Provide a safe transition for profiles used by older builders, coordinating with both lock protocols or preventing incompatible versions from using the profile until they are updated. Cover both an old holder and an old builder starting after a launcher edit.

**L1** (blocking): The new lock protocol is incompatible with installed builders that still use the existence of this file as their lock. *When:* After any launcher profile edit, the empty file remains in place, so a pre-nightly-1179 builder cannot acquire its old-style lock for the game's mod prompts or switches. Conversely, if an old builder already holds its timestamped file, the launcher takes an OS lock on it anyway, allowing concurrent profile edits and potentially lost changes. **Do:** Provide a safe transition for profiles used by older builders, coordinating with both lock protocols or preventing incompatible versions from using the profile until they are updated. Cover both an old holder and an old builder starting after a launcher edit.
@ -115,0 +107,4 @@
.context("Could not lock profile.json for editing.")?;
let deadline = Instant::now() + Duration::from_secs(2);
loop {
match file.try_lock() {
Member

L2 (should fix): The changed platform locking path has not been exercised on Linux with the actual builder.

When: Linux installs and updates rely on the launcher and builder excluding one another and accepting a released lock file; the recorded hand test covers Windows only.

Do: Run a Linux install or update with the nightly-1179 builder and check contention and release between the builder and launcher.

**L2** (should fix): The changed platform locking path has not been exercised on Linux with the actual builder. *When:* Linux installs and updates rely on the launcher and builder excluding one another and accepting a released lock file; the recorded hand test covers Windows only. **Do:** Run a Linux install or update with the nightly-1179 builder and check contention and release between the builder and launcher.
fix(profiles): the edit lock keeps builders from before Longshot nightly-1179 out too (#426)
Some checks are pending
CI / What the change needs (pull_request) Waiting to run
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Waiting to run
CI / Rust formatting, lint and tests (pull_request) Blocked by required conditions
CI / Release packages and stable upgrades (pull_request) Blocked by required conditions
PR title / Conventional Commit title (pull_request) Waiting to run
d251ab1888
A builder before nightly-1179 holds .longshot-edit.lock the old way: the
file made with "<pid> <epoch seconds>" in it, free when gone, unreadable or
over 30 seconds old. While the launcher holds the OS lock the file now carries
that text, and it is emptied before the lock is let go, so such a builder
waits for the launcher's edit and finds the file free after it. A fresh text of
that form keeps the launcher waiting in turn. Where an old builder could have
moved the file aside as stale between the launcher's lock and its text
(not Windows, where a locked file can't be read), the launcher takes it again.

Review: BeanBot L1 on #427.

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

Thanks, BeanBot. Pushed d251ab1.

L1: fixed for the case that was real. One half didn't hold: after a Launcher edit, a builder from before nightly-1179 does take the lock, since its stale() (Longshot nightly-981, builder/crates/launcher-profile/src/edit.rs) treats a file it can't parse, the empty one included, as free and moves it aside. The other half was right: an old builder holding its <pid> <time> file didn't keep the Launcher out. Now:

  • while the Launcher holds the OS lock, the file also carries <pid> <epoch seconds>, and it is emptied before the lock is let go: an old builder waits for the Launcher's edit (on Windows it can't even read the locked file) and finds the file free after it;
  • a fresh text of that form (taken at most 30 s ago) keeps the Launcher waiting in turn; an older one, or one ahead of the clock, doesn't;
  • where an old builder could move the file aside between the Launcher's lock and its text (not Windows), the Launcher checks the path still names its file and takes it again if not.

The 1179 builder ignores the text, so nothing changes with it. Two new tests cover an old holder and an old builder starting after a Launcher edit. On Windows: Clippy, rustfmt, the suite (353 passed), and the Launcher again with this commit (a fresh install of nightly-1179 and the update with fast check: current, both "Build completed", the lock file left empty).

L2: the players tests (25, the four lock tests among them) and Clippy pass on Linux (Ubuntu 24.04 in WSL 2). A run of the Launcher itself with the real Linux builder isn't possible here, so:

@Beanstalk On Linux, with this PR's Launcher: install or update a version to nightly-1179 (or newer) and check it ends with "Build completed", not "Another editor is changing this profile". Then rename a save or change the game language in the Launcher, and check it goes through.

@review

Thanks, BeanBot. Pushed d251ab1. **L1:** fixed for the case that was real. One half didn't hold: after a Launcher edit, a builder from before nightly-1179 does take the lock, since its `stale()` (Longshot nightly-981, `builder/crates/launcher-profile/src/edit.rs`) treats a file it can't parse, the empty one included, as free and moves it aside. The other half was right: an old builder holding its `<pid> <time>` file didn't keep the Launcher out. Now: - while the Launcher holds the OS lock, the file also carries `<pid> <epoch seconds>`, and it is emptied before the lock is let go: an old builder waits for the Launcher's edit (on Windows it can't even read the locked file) and finds the file free after it; - a fresh text of that form (taken at most 30 s ago) keeps the Launcher waiting in turn; an older one, or one ahead of the clock, doesn't; - where an old builder could move the file aside between the Launcher's lock and its text (not Windows), the Launcher checks the path still names its file and takes it again if not. The 1179 builder ignores the text, so nothing changes with it. Two new tests cover an old holder and an old builder starting after a Launcher edit. On Windows: Clippy, rustfmt, the suite (353 passed), and the Launcher again with this commit (a fresh install of nightly-1179 and the update with `fast check: current`, both "Build completed", the lock file left empty). **L2:** the players tests (25, the four lock tests among them) and Clippy pass on Linux (Ubuntu 24.04 in WSL 2). A run of the Launcher itself with the real Linux builder isn't possible here, so: @Beanstalk On Linux, with this PR's Launcher: install or update a version to nightly-1179 (or newer) and check it ends with "Build completed", not "Another editor is changing this profile". Then rename a save or change the game language in the Launcher, and check it goes through. @review
BeanBot left a comment

Recommendation: Request changes. The new lock fixes the reported nightly-1179 failure in the Windows install and update runs, but it still permits an old builder and the Launcher to edit the same profile concurrently on Linux.

The Launcher now uses the builder’s OS lock and writes a legacy lock record for older builders. This restores the reported install and update flow, but the compatibility protocol retains a race that can lose profile edits.

Blocking (1): must change before merging.

  1. L1 src/players/profiles.rs:106: The path check can complete before an old builder acts on a stale read of the lock file. When: On Linux, an old builder reads the empty file as free and pauses. The Launcher locks it, writes its token and passes the path check; the builder then moves that file aside, creates its own lock and edits the profile concurrently, allowing one edit to overwrite the other. Do: Use an interoperability protocol that prevents a legacy builder’s pending stale-file rename from displacing the lock during an edit, and cover the delayed-rename interleaving.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 src/players/profiles.rs:110: The changed platform locking path has not been exercised on Linux with the actual builder. When: Linux installs and updates rely on the launcher and builder excluding one another and accepting a released lock file; the recorded hand test covers Windows only. Do: Run a Linux install or update with the nightly-1179 builder and check contention and release between the builder and launcher.

@fix can do L1.

Since the last review (on 47f688fe8f)
Still open: L1 (The path check can complete before an old builder acts on a stale read of the lock file.); L2 (The changed platform locking path has not been exercised on Linux with the actual builder.)

Checks: Still running: 5 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes. The reported Windows runs show both a fresh install and an update completing after registration; main failed at that step. Linux lock tests passed, but a real Linux builder interoperability run is still outstanding.

Other systems: The lock also protects save-name, language, mod and build-option edits. The reported Windows and Linux tests exercise the lock, but do not cover the delayed legacy-builder rename race on Linux.

Switches: None.

Reviewed: d251ab1888 against 48e2d127a6: Read AGENTS.md, CONTRIBUTING.md, the full diff, profiles.rs, the changed tests and FileLease; skimmed the remaining tests and lock callers. No review checklist or pull request template was found.; nothing run (a code review).

Checked and fine:

  • A fresh legacy token keeps the Launcher waiting, and the Launcher clears its token before releasing its OS lock.
  • The reported Windows fresh install and update completed with nightly-1179.
  • The description explains the change, tests and remaining Linux run.

Testing: No commands that run project code were executed. The author reports Windows suite, lint and real-builder install and update runs, plus Linux player tests and lint; CI is still running.

Overlaps and merge order: None identified from the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The new lock fixes the reported nightly-1179 failure in the Windows install and update runs, but it still permits an old builder and the Launcher to edit the same profile concurrently on Linux. The Launcher now uses the builder’s OS lock and writes a legacy lock record for older builders. This restores the reported install and update flow, but the compatibility protocol retains a race that can lose profile edits. **Blocking (1)**: must change before merging. 1. **L1** `src/players/profiles.rs:106`: The path check can complete before an old builder acts on a stale read of the lock file. *When:* On Linux, an old builder reads the empty file as free and pauses. The Launcher locks it, writes its token and passes the path check; the builder then moves that file aside, creates its own lock and edits the profile concurrently, allowing one edit to overwrite the other. **Do:** Use an interoperability protocol that prevents a legacy builder’s pending stale-file rename from displacing the lock during an edit, and cover the delayed-rename interleaving. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `src/players/profiles.rs:110`: The changed platform locking path has not been exercised on Linux with the actual builder. *When:* Linux installs and updates rely on the launcher and builder excluding one another and accepting a released lock file; the recorded hand test covers Windows only. **Do:** Run a Linux install or update with the nightly-1179 builder and check contention and release between the builder and launcher. `@fix` can do L1. **Since the last review** (on 47f688fe8f86) Still open: L1 (The path check can complete before an old builder acts on a stale read of the lock file.); L2 (The changed platform locking path has not been exercised on Linux with the actual builder.) **Checks:** Still running: 5 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The reported Windows runs show both a fresh install and an update completing after registration; main failed at that step. Linux lock tests passed, but a real Linux builder interoperability run is still outstanding. **Other systems:** The lock also protects save-name, language, mod and build-option edits. The reported Windows and Linux tests exercise the lock, but do not cover the delayed legacy-builder rename race on Linux. **Switches:** None. **Reviewed:** d251ab1888d4 against 48e2d127a688: Read AGENTS.md, CONTRIBUTING.md, the full diff, profiles.rs, the changed tests and FileLease; skimmed the remaining tests and lock callers. No review checklist or pull request template was found.; nothing run (a code review). **Checked and fine:** - A fresh legacy token keeps the Launcher waiting, and the Launcher clears its token before releasing its OS lock. - The reported Windows fresh install and update completed with nightly-1179. - The description explains the change, tests and remaining Linux run. **Testing:** No commands that run project code were executed. The author reports Windows suite, lint and real-builder install and update runs, plus Linux player tests and lint; CI is still running. **Overlaps and merge order:** None identified from the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
Author
Member

L1 (delayed rename on Linux): right, and it stays, deliberately. The window can't be closed from the Launcher's side:

  • On Linux nothing in or on the file stops another process from renaming it; flock is advisory and the old builder never asks for it. The Launcher's text, its path check and its OS lock all happen before a rename an old builder already decided on.
  • It is the old protocol's own race: two old builders have it between themselves (Longshot #3020 removed the scheme for that reason), and an old builder has it with the 1179 builder, whose empty file it also moves aside.
  • It needs a game from before nightly-1179 running on that profile (that's when an old builder edits it: its build start and its game's channel) and a Launcher edit of the same profile in the same instant, with the old builder paused between its read and its rename.
  • Closing it would mean changing the old builders, which are released and fixed; deleting the file instead of leaving it would bring back the two-holders race #3020 fixed for the current builders.

So this PR keeps the old builders out everywhere the Launcher can see them (a fresh old-style text, and on Windows a locked file they can't read), and the description's Not covered now names the window. A maintainer decides whether that is enough.

L2: still with the Test Farm (asked above).

**L1 (delayed rename on Linux):** right, and it stays, deliberately. The window can't be closed from the Launcher's side: - On Linux nothing in or on the file stops another process from renaming it; `flock` is advisory and the old builder never asks for it. The Launcher's text, its path check and its OS lock all happen before a rename an old builder already decided on. - It is the old protocol's own race: two old builders have it between themselves (Longshot #3020 removed the scheme for that reason), and an old builder has it with the 1179 builder, whose empty file it also moves aside. - It needs a game from before nightly-1179 running on that profile (that's when an old builder edits it: its build start and its game's channel) and a Launcher edit of the same profile in the same instant, with the old builder paused between its read and its rename. - Closing it would mean changing the old builders, which are released and fixed; deleting the file instead of leaving it would bring back the two-holders race #3020 fixed for the current builders. So this PR keeps the old builders out everywhere the Launcher can see them (a fresh old-style text, and on Windows a locked file they can't read), and the description's *Not covered* now names the window. A maintainer decides whether that is enough. **L2:** still with the Test Farm (asked above).
HumanBean deleted branch fix/profile-edit-lock-os-lock 2026-12-05 21:02:48 +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!427
No description provided.