feat(versions): versions are their folders, and an update changes a version in place #352

Merged
HumanBean merged 4 commits from HumanBean/LongshotLauncher:feat/version-folders-in-place into main 2026-11-28 21:50:21 +00:00
Owner

The launcher kept every version in one versions.json beside the folders, and updated a version by building the new release in a staging folder and swapping it in, with retired folders kept for rollback. Two copies of the truth drifted apart, and the swap is the most fragile step a player runs. This PR makes each version folder describe itself and updates a version where it is.

What changes

Versions are folders (commit 1)

  • Each version folder holds version.json, written last when its build completes: id, tag, channel, game source, upscaler modules, earlier tags, created and updated. A folder with it is a complete version; without it, it is not one. No retired or half-registered states.
  • The Versions list is a scan of the folders (the launcher's own and the configured library). Several copies of one tag are separate versions with their own ids; a copied folder that carries another folder's id gets an id of its own (<id>-<16 hex>), the first keeps it.
  • What belongs to no one version, the default choice, lives in library.json. If it is lost, only the default choice is lost.
  • Migration on first start: the old versions.json (or, before it, the builder-made rows of the stable launcher's builds.json) is read once; each listed folder gets its version.json with the same id, so profile.json version and Steam --play <id> keep working. Playable folders the old launcher found without listing them get their old copy-<sha256> or folder-name id. The list is kept as versions.json.backup; builds.json is never written. library.json, written last, marks the migration done; an unreadable list leaves everything as it is and is tried again on the next start.
  • Every reader of versions.json moved to the folders: library, recovery (a renamed custom-library folder keeps its ownership record), Steam shortcuts and their old folders, prune, storage protection and reclaim, shader cache, folder moves (records move with the folders; a move an earlier launcher left interrupted still finishes), portable relocation (each record's game source is repaired), the live file watcher.

Update in place (commit 2)

  • An update puts the new release's tools into the same version folder (the builder's fetch or the signed download, into a temporary folder inside the version, then moved over the old tools, builder last), records the new tag, then runs the builder's build there. No staging version folder, no swap: replace_instance, the upgrade file carrying, retired folders and prune's retired cleanup are removed.
  • A cancelled or failed update leaves the game it had: Play rebuilds, and a failed rebuild keeps the game. Saves, settings and runtime files stay in builds/default. The update is refused while the version or its profile is in use (players::ensure_paths_idle); on Windows a file in use is retried for 3 s, then a message names the file and says to close it and choose Update again.
  • Until the builder-side redesign lands, the rebuild runs today's build --profile <profile> --game … --language … --upscaler … [--accept-licenses …]. The update keeps the folder's built language and its modules. Every build and fetch command line comes from one function each in src/game/builder_cli.rs, so a later PR changes the flags in one place. The builder repo is unchanged.
  • Rollback dropped: previousFolder, previousVersion, retiredFolders, the rollbackVersion / updatedToVersion settings and the storage scan's rollback pin are gone. No rollback UI existed, so no screen changes.

Docs (commit 3): docs/paths.md (new "Updating a version" section) and the README line on game updates.

Old retired folders removed (commit 4): folders an earlier launcher retired or left from a staged update (its .longshot-retired receipt, or named in the old retiredFolders) are removed once by the migration and again by each update in place. Only a folder the launcher owns that no version.json describes, that no profile names or holds its game in, that nothing uses (ensure_paths_idle), and that holds no saves or settings. A failure is logged and the update carries on.

Commit 1 does not build by itself (the wizard still calls the old registration); review in order, build the head.

Supersedes the dedupe idea of #351 (closed): several instances of one tag stay separate.

Checks

  • cargo check --locked --tests, cargo clippy --locked --all-targets -- -D warnings, cargo fmt --check pass on Linux.
  • Unit tests written (migration, copies and ids, lost library.json, portable relocation, in-place update in the wizard and in update_tools, tool replacement, prune, retired-folder removal, recovery, folder moves) but not run: no tests are run on the PC this was written on. CI runs them.
  • Windows build not checked here (no Windows toolchain); the Windows-only paths I touched are cfg! expressions only.
  • Not run in the launcher: no real update, no migration of a real home, no Steam shortcut retarget, no Windows lock seen. An update in place on Linux and Windows, a migration of a home with several versions and retired folders, a portable drive, and a running game during an update need trying before this leaves WIP.

πŸ€– Generated with Claude Code

The launcher kept every version in one versions.json beside the folders, and updated a version by building the new release in a staging folder and swapping it in, with retired folders kept for rollback. Two copies of the truth drifted apart, and the swap is the most fragile step a player runs. This PR makes each version folder describe itself and updates a version where it is. ## What changes **Versions are folders** (commit 1) - Each version folder holds `version.json`, written last when its build completes: id, tag, channel, game source, upscaler modules, earlier tags, created and updated. A folder with it is a complete version; without it, it is not one. No retired or half-registered states. - The Versions list is a scan of the folders (the launcher's own and the configured library). Several copies of one tag are separate versions with their own ids; a copied folder that carries another folder's id gets an id of its own (`<id>-<16 hex>`), the first keeps it. - What belongs to no one version, the default choice, lives in `library.json`. If it is lost, only the default choice is lost. - **Migration on first start**: the old versions.json (or, before it, the builder-made rows of the stable launcher's builds.json) is read once; each listed folder gets its `version.json` with the **same id**, so profile.json `version` and Steam `--play <id>` keep working. Playable folders the old launcher found without listing them get their old `copy-<sha256>` or folder-name id. The list is kept as `versions.json.backup`; builds.json is never written. `library.json`, written last, marks the migration done; an unreadable list leaves everything as it is and is tried again on the next start. - Every reader of versions.json moved to the folders: library, recovery (a renamed custom-library folder keeps its ownership record), Steam shortcuts and their old folders, prune, storage protection and reclaim, shader cache, folder moves (records move with the folders; a move an earlier launcher left interrupted still finishes), portable relocation (each record's game source is repaired), the live file watcher. **Update in place** (commit 2) - An update puts the new release's tools into the **same** version folder (the builder's `fetch` or the signed download, into a temporary folder inside the version, then moved over the old tools, builder last), records the new tag, then runs the builder's `build` there. No staging version folder, no swap: `replace_instance`, the upgrade file carrying, retired folders and prune's retired cleanup are removed. - A cancelled or failed update leaves the game it had: Play rebuilds, and a failed rebuild keeps the game. Saves, settings and runtime files stay in `builds/default`. The update is refused while the version or its profile is in use (`players::ensure_paths_idle`); on Windows a file in use is retried for 3 s, then a message names the file and says to close it and choose Update again. - Until the builder-side redesign lands, the rebuild runs today's `build --profile <profile> --game … --language … --upscaler … [--accept-licenses …]`. The update keeps the folder's built language and its modules. Every `build` and `fetch` command line comes from one function each in `src/game/builder_cli.rs`, so a later PR changes the flags in one place. The builder repo is unchanged. - **Rollback dropped**: `previousFolder`, `previousVersion`, `retiredFolders`, the `rollbackVersion` / `updatedToVersion` settings and the storage scan's rollback pin are gone. No rollback UI existed, so no screen changes. **Docs** (commit 3): docs/paths.md (new "Updating a version" section) and the README line on game updates. **Old retired folders removed** (commit 4): folders an earlier launcher retired or left from a staged update (its `.longshot-retired` receipt, or named in the old `retiredFolders`) are removed once by the migration and again by each update in place. Only a folder the launcher owns that no `version.json` describes, that no profile names or holds its game in, that nothing uses (`ensure_paths_idle`), and that holds no saves or settings. A failure is logged and the update carries on. Commit 1 does not build by itself (the wizard still calls the old registration); review in order, build the head. Supersedes the dedupe idea of [#351](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/351) (closed): several instances of one tag stay separate. ## Checks - [x] `cargo check --locked --tests`, `cargo clippy --locked --all-targets -- -D warnings`, `cargo fmt --check` pass on Linux. - [ ] Unit tests written (migration, copies and ids, lost library.json, portable relocation, in-place update in the wizard and in `update_tools`, tool replacement, prune, retired-folder removal, recovery, folder moves) but **not run**: no tests are run on the PC this was written on. CI runs them. - [ ] Windows build not checked here (no Windows toolchain); the Windows-only paths I touched are `cfg!` expressions only. - [ ] Not run in the launcher: no real update, no migration of a real home, no Steam shortcut retarget, no Windows lock seen. An update in place on Linux and Windows, a migration of a home with several versions and retired folders, a portable drive, and a running game during an update need trying before this leaves WIP. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
versions.json is read once, written into each folder's record with the same ids,
and kept as versions.json.backup. The default choice lives in library.json,
which can be rebuilt. Copies of one release are separate versions, each with
its own id. Retired folders and rollback records are gone.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
No staging folder, swap or rollback. The builder's command line is built in one
place, game/builder_cli.rs. A cancelled or failed update leaves the game
it had for Play to rebuild. The update is refused while the version or its
profile is in use, and a Windows file lock gives a message and a retry.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
docs(paths): version.json, library.json and the update in place
Some checks failed
CI / What the change needs (pull_request) Successful in 6s
PR title / Conventional Commit title (pull_request) Successful in 8s
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Successful in 13s
CI / Rust formatting, lint and tests (pull_request) Has been cancelled
CI / Release packages and stable upgrades (pull_request) Has been cancelled
9a016b63fb
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Member

Possibly related, for context:

  • issue #350 Launcher: the same version is listed twice (two rows with one tag) β€” Directly concerns version-folder ownership and multiple copies per tag
  • issue #329 Launcher: Nightly update build completes but registration is refused because destination folder is non-empty β€” Update registration failure; this changes the update destination and registration flow
  • PR #184 feat(builds): an instance's folder is builds//, renamed when it updates β€” Merged design for version-named folders and update renaming, replaced by this PR
  • PR #288 feat(versions): one list of installed versions per launcher, and a version to add is never an empty list β€” Merged PR introduced versions.json registry that this migrates away from
Possibly related, for context: - issue #350 Launcher: the same version is listed twice (two rows with one tag) β€” Directly concerns version-folder ownership and multiple copies per tag - issue #329 Launcher: Nightly update build completes but registration is refused because destination folder is non-empty β€” Update registration failure; this changes the update destination and registration flow - PR #184 feat(builds): an instance's folder is builds/<track>/<version>, renamed when it updates β€” Merged design for version-named folders and update renaming, replaced by this PR - PR #288 feat(versions): one list of installed versions per launcher, and a version to add is never an empty list β€” Merged PR introduced versions.json registry that this migrates away from
feat(versions): the migration and each update in place remove folders earlier launchers retired
Some checks failed
CI / What the change needs (pull_request) Successful in 6s
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Successful in 10s
CI / Release packages and stable upgrades (pull_request) Failing after 58s
CI / Rust formatting, lint and tests (pull_request) Failing after 12m15s
PR title / Conventional Commit title (pull_request) Successful in 8s
0b9c314b05
Only a folder the launcher owns, that no version.json describes, no profile
names or holds its game in, that nothing uses and that holds no saves or
settings. A failure is logged and the update carries on.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
HumanBean changed title from WIP: feat(versions): versions are their folders, and an update changes a version in place to feat(versions): versions are their folders, and an update changes a version in place 2026-11-28 21:50:14 +00:00
HumanBean deleted branch feat/version-folders-in-place 2026-11-28 21:50:21 +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!352
No description provided.