The app asks the project's Gitea release list about five seconds after startup and every six hours. A stable release beats a newer prerelease, and a release is offered only when its tag is newer than the running build and it carries a .capsule asset for this target. A capsule is a ZIP with capsule.json and a payload. Every payload file carries its size and BLAKE3 digest in the manifest, and staging rejects absolute paths, parent segments, undeclared entries, digest mismatches, and versions that are not newer. The verified payload is stored under the app data directory, so a download survives a restart. The manifest and archive format live in crates/capsule-format, shared by the app's verifier and the release tool. Settings > Advanced shows the state, the notes, and the download and install buttons. The status bar shows an accent chip while an update is waiting. Install copies the app to a temp helper, asks the daemon to stop, and quits. The helper waits for the process, swaps the files with a rollback copy of each old file, removes stale files, and starts the new app. A failed swap puts the old files back and logs the reason. --check-updates runs the release check from a shell. The release tool in tools/capsule builds a capsule from the same files the installer puts down, using packager.toml, so a release does not need an installed copy. docs/updates.md covers the format and the release steps.
5.8 KiB
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:
{
"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.jsonis 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 incapsule.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/<version>/. 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/:
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-<version>-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 <file> to write somewhere else. The tool also accepts
--folder <install-root> --version <x.y.z> --out <file> 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 <staged-folder> <install-folder> <app-pid>
The helper waits for that process to exit, then:
- copies each new file beside its target as
<name>.lrnew; - moves each old file aside as
<name>.lrold, then renames the new file into place; - removes the files named in
remove; - deletes the
.lroldcopies and the staging folder; - 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. |