# Updates The app checks the project's Gitea release list, downloads a `.capsule` asset, verifies every file in it, and replaces the install with a small helper process. ## The check `src/update.rs` reads: ``` https://git.vhaudiquet.fr/api/v1/repos/vhaudiquet/leaguerecorder/releases?limit=60 ``` The first automatic check runs about five seconds after startup. Later ones run every six hours, only while the app is open. The check runs on its own thread, so the window never waits on the network. A manual check is in Settings > Advanced, under Updates. When a release is waiting, the status bar carries a yellow **Update available** chip beside the daemon state; it opens Settings > Advanced. The chip turns into **Update ready** once the capsule is staged. A release is offered when all of these hold: - it is not a draft; - its tag parses as a version, with or without a leading `v`; - the version is newer than the running build; - it has an asset whose name ends in `.capsule`. A stable release beats a newer prerelease. The project currently marks every release as a prerelease at Gitea, so the check falls back to prereleases when that is all it finds. `--check-updates` runs the same check from a shell and prints the result. ## The capsule A capsule is a ZIP file with this layout: ``` capsule.json payload/leaguerecorder.exe payload/record-daemon.exe payload/... ``` `capsule.json` looks like this: ```json { "format": 1, "product": "leaguerecorder", "version": "0.4.0", "target": "windows-x86_64", "entry": "leaguerecorder.exe", "notes": "", "files": [ { "path": "leaguerecorder.exe", "size": 67496448, "blake3": "5a3c..." } ], "remove": [] } ``` `path` is relative to the install root and always uses forward slashes. `blake3` is the lowercase hex digest of the file. `remove` names files from an older install that the new version no longer ships; it is optional and empty by default. The downloader refuses a capsule when: - the ZIP cannot be read, or `capsule.json` is missing or malformed; - the manifest format, product, or target does not match this build; - any path is absolute, contains `..`, a backslash, a drive prefix, or an empty segment; - a file in `payload/` is not named in `capsule.json`; - a size or BLAKE3 digest does not match; - the version is not newer than the running build. The extracted payload is kept under the app data directory in `updates//`. A complete stage is found again on the next start, so an update downloaded before a restart can still be installed. ## Building a capsule The release tool builds the install tree from `packager.toml` and packs it. It does not need an installed copy, and the app has no packaging mode. Build the release, then run the tool from `app/`: ```sh cargo packager --release cargo run --manifest-path ../tools/capsule/Cargo.toml -- --config packager.toml ``` `cargo packager` builds both programs and writes the NSIS installer. The tool reads the same release binaries, so the capsule carries the files the installer puts down. It writes `dist/leaguerecorder--windows-x86_64.capsule`, using the version in `packager.toml`. The tool also checks that `Cargo.toml` carries that version, so a release cannot pack one version's files under another version's manifest. Pass `--out ` to write somewhere else. The tool also accepts `--folder --version --out ` for a tree that is already assembled. The builder skips `.capsule`, `.lrnew`, and `.lrold` files. It writes an empty `remove` list. If a release drops a file, unzip the capsule, add the path to `remove` in `capsule.json`, and zip it again with `capsule.json` at the root. The payload hashes stay valid. Upload the `.capsule` as an asset on the Gitea release whose tag matches the version. The manifest version and the tag should name the same release. The check compares tags, and staging compares the manifest. Put the target in the asset name (`windows-x86_64`) so a machine picks the right one when a release carries several builds. ## Installing Press **Download** in Settings > Advanced. The app downloads the capsule, verifies it, and leaves it staged. Press **Restart and install**. The app starts a copy of itself from the temp folder, asks the daemon to stop, then quits. The copy is started with: ``` --apply-update ``` The helper waits for that process to exit, then: 1. copies each new file beside its target as `.lrnew`; 2. moves each old file aside as `.lrold`, then renames the new file into place; 3. removes the files named in `remove`; 4. deletes the `.lrold` copies and the staging folder; 5. starts the installed `leaguerecorder.exe`. A failure at any step puts the old files back, starts the old app, and writes the reason to `updates/update.log` in the app data directory. On Windows that is `%LOCALAPPDATA%\leaguerecorder\leaguerecorder\data\updates`. If the daemon still holds a file, the whole install is retried once a second for 30 seconds. The Open update folder button in the same card opens that folder. ## What this does not protect against The app reads the release page over HTTPS and checks each file against the manifest inside the same capsule. That detects a broken or truncated download. It does not detect a server that serves a matching capsule and manifest, because the manifest is not signed. Signing the exe and the capsule remains a separate task. Until then, a compromised Gitea account or DNS can install arbitrary code, and Windows SmartScreen still warns on the first run. ## Environment variables | Name | Use | | --- | --- | | `LEAGUERECORDER_RELEASES_URL` | Read a different release list, such as a mirror or a test server. | | `LEAGUERECORDER_UPDATE_DIR` | Put staged capsules and `update.log` somewhere else. | | `LEAGUERECORDER_NO_UPDATE_CHECK` | Turn the automatic check off for this process. |