app: check Gitea releases and install update capsules
record-daemon / Check and lint (Linux) (push) Successful in 1m5s
record-daemon / Build (Windows x64) (push) Successful in 1m54s

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.
This commit is contained in:
vhaudiquet committed 2026-11-24 21:59:17 +01:00
1 parent 9d1fb40434
commit e3a62aa6ae
17 files changed
+3535 -6

No files matched your search

+15
View File
@@ -530,6 +530,17 @@ dependencies = [
"wayland-client",
]
[[package]]
name = "capsule-format"
version = "0.1.0"
dependencies = [
"blake3",
"semver",
"serde",
"serde_json",
"zip",
]
[[package]]
name = "cc"
version = "1.11.2"
@@ -1549,6 +1560,8 @@ checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
name = "leaguerecorder"
version = "0.3.3"
dependencies = [
"blake3",
"capsule-format",
"chrono",
"directories",
"ffmpeg-sidecar",
@@ -1556,6 +1569,7 @@ dependencies = [
"rune",
"rune-kit",
"rune-notify",
"semver",
"serde",
"serde_json",
"tokio",
@@ -1564,6 +1578,7 @@ dependencies = [
"windows",
"winreg",
"winresource",
"zip",
]
[[package]]
+6
View File
@@ -17,6 +17,7 @@ winresource = "0.1"
rune = { path = "vendor/rune/crates/rune", features = ["native-file-dialog"] }
rune-kit = { path = "vendor/rune/crates/rune-kit" }
rune-notify = { path = "vendor/rune/crates/rune-notify" }
capsule-format = { path = "../crates/capsule-format" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
@@ -26,6 +27,11 @@ tokio = { version = "1", features = ["rt", "net", "io-util", "time", "sync"] }
uuid = { version = "1", features = ["v4", "serde"] }
ffmpeg-sidecar = "2.7"
ureq = "3.5"
# Updates: the Gitea release list over ureq, a capsule is a ZIP, and every file in it carries
# a BLAKE3 digest.
semver = "1"
blake3 = "1"
zip = { version = "9.6", default-features = false, features = ["deflate-flate2"] }
# PNG decode of the bundled tray icon; the same crate and features rune itself uses.
image = { version = "0.25", default-features = false, features = ["png"] }
+22
View File
@@ -74,6 +74,7 @@ reading (`history::tests`), highlight clipping (`highlight::tests`) and formatti
| `src/export.rs` | ffmpeg clip export, the clips folder it fills and its miniatures |
| `src/os.rs` | Run key, toasts, tray icon and menu |
| `src/ui.rs` | Colours, cards, switches, sliders, buttons |
| `src/update.rs` | Release checks, the capsule format, staging, and the apply helper |
| `src/screens/` | Settings, match history, clips, game review, the recording in progress |
## Where this stands against TODO.txt
@@ -118,6 +119,9 @@ reading (`history::tests`), highlight clipping (`highlight::tests`) and formatti
runtime beside the exe. `cargo install cargo-packager --locked && cargo packager --release`.
On the first run the app downloads ffmpeg (`--fetch-ffmpeg` does it from a shell), so clip
export is ready before the first clip. The installer has not been run on a clean VM yet.
10. Updates: the app checks Gitea releases, downloads a capsule, verifies it, and restarts into
a helper that swaps the files. The apply path has been exercised on a scratch folder; it has
not run against a capsule published on Gitea yet.
### The recording screen
@@ -136,6 +140,24 @@ in Match history as a game that never happened, next to one with no champion. Th
the open timeline into the one holding the video (`history::close_stopped`), and "Stop and
delete" removes the clip and both.
## Updates
The app checks the project's Gitea releases about five seconds after startup, then every six
hours. Settings > Advanced has the running version, the result, and the buttons that download a
release and restart to install it. A release carries a `.capsule` asset: a ZIP with
`capsule.json` at the root and every install file under `payload/`. The manifest names each
file with a size and BLAKE3 digest, and the app checks every one before it stages the update.
`../tools/capsule` builds a capsule from the release tree and `packager.toml`, without an
installed copy. `--check-updates` runs the same check from a shell. The restart starts a copy
of the app from the temp folder; that copy waits for the app and daemon to exit, replaces the
files, and starts the new app. A failed replace puts the old files back and writes
`update.log` under the app data directory. `../docs/updates.md` has the format, the release
steps, and the limits.
The capsule is not signed. HTTPS and the per-file digests detect a broken or truncated
download, not a server that serves a matching capsule.
### Known gaps
- Item images are not drawn. Champion portraits download from Data Dragon on first sight and are
+4
View File
@@ -3,6 +3,10 @@
# The app exe is the cargo binary. Everything the daemon needs at run time sits beside it in the
# install root: the daemon, OBS and its data are built into record-daemon/target/release by the
# daemon's own build and copied from there. The app downloads ffmpeg itself on the first export.
# After packaging, build the matching update capsule from the same release files and upload it
# to the Gitea release:
# cargo run --manifest-path ../tools/capsule/Cargo.toml -- --config packager.toml
# See ../docs/updates.md for the format and the release steps.
"$schema" = "https://raw.githubusercontent.com/crabnebula-dev/cargo-packager/main/crates/packager/schema.json"
name = "leaguerecorder"
+116 -4
View File
@@ -2,9 +2,9 @@
use std::path::PathBuf;
use std::sync::mpsc::{Receiver, TryRecvError, channel};
use std::time::Duration;
use std::time::{Duration, Instant};
use rune::tok::type_;
use rune::tok::{radius, type_};
use rune::{ChromeInsets, Cx, El, Key, KeyEvent, Tx, col, el, row, text};
use crate::export::{self, Clip};
@@ -188,6 +188,11 @@ pub struct App {
/// ffmpeg being downloaded on the first run, and the whole percent it last reported.
pub ffmpeg_rx: Option<Receiver<export::FetchEvent>>,
pub ffmpeg_pct: Option<u64>,
/// The release check, the capsule being downloaded, and the one waiting to install.
pub update: crate::update::Updates,
/// When the user pressed Restart and install: the daemon gets a moment to stop before
/// the app quits and the helper replaces its files.
pub quitting_for_update: Option<Instant>,
pub autostart: bool,
pub logs: String,
pub pending_review: bool,
@@ -251,6 +256,8 @@ impl App {
notice: None,
ffmpeg_rx: None,
ffmpeg_pct: None,
update: crate::update::Updates::new(),
quitting_for_update: None,
autostart,
logs: String::new(),
pending_review: false,
@@ -368,6 +375,7 @@ impl App {
},
];
self.form.apply(&settings);
self.update.demo_available();
// The sample sources read as a running process and one that is not, so a snapshot
// shows both states of the chip.
self.processes = settings
@@ -765,6 +773,11 @@ pub fn setup(app: &mut App, waker: rune::Waker) {
app.icons = Some(rune::ImageCache::new(waker.clone()));
app.thumbs = Some(rune::ImageCache::new(waker.clone()));
app.daemon.set_waker(waker.clone());
// A snapshot run reads nothing from the network: the update card keeps its "not checked"
// state unless the scene gives it demo data.
if headless() {
app.update.auto = false;
}
app.refresh_settings();
app.refresh_games();
app.daemon.get_status();
@@ -841,10 +854,65 @@ impl App {
}
}
impl App {
/// Keep the release check moving and turn its results into notices. The worker sends on a
/// channel, so this never waits on the network.
fn poll_updates(&mut self, t: f64) -> bool {
let (news, arrived) = self.update.drain();
let mut changed = arrived;
for news in news {
changed = true;
match news {
crate::update::News::Available(available) => self.notify(format!(
"League Recorder {} is available. Settings > Advanced downloads it.",
available.version
)),
crate::update::News::UpToDate => self.notify("League Recorder is up to date"),
crate::update::News::Ready(staged) => self.notify(format!(
"Update {} is ready. Restart from Settings > Advanced to install it.",
staged.version
)),
crate::update::News::Error(e) => self.notify_error(format!("Update: {e}")),
}
}
changed | self.update.tick(t)
}
/// Download and install the staged capsule. The update helper waits for this process to
/// exit, so the app stays up long enough to ask the daemon to stop and flush that request.
pub fn install_update(&mut self, tx: &mut Tx) {
if self.status.is_recording {
self.notify_error("Stop the recording before installing an update.");
return;
}
match self.update.install() {
Ok(()) => {
self.daemon.shutdown();
self.quitting_for_update = Some(Instant::now());
self.notify("Restarting to install the update...");
tx.wake_after(Duration::from_millis(300));
}
Err(e) => self.notify_error(e),
}
}
}
impl App {
fn handle_poll(&mut self, t: f64, tx: &mut Tx) -> bool {
let mut changed = false;
// A staged update asks the daemon to stop, then quits so the helper can replace the
// files. The short pause is for the shutdown request to leave this process.
if let Some(at) = self.quitting_for_update {
if at.elapsed() >= Duration::from_millis(1500) {
tx.quit();
} else {
tx.wake_after(Duration::from_millis(200));
}
}
changed |= self.poll_updates(t);
// Being full screen is a state of the window, not only of the review: the view drops
// the title bar and the status bar the moment the review asks for it, and the window
// follows in the same frame. Any way out of the review, or off the screen it was on,
@@ -1275,8 +1343,11 @@ fn statusbar(p: Paint, app: &App) -> El {
.key("status-text")
.font(body(11.5))
.color(p.muted()),
)
.child(el().grow(1.0));
);
if let Some(chip) = update_chip(app, p) {
bar = bar.child(chip);
}
bar = bar.child(el().grow(1.0));
if let Some(note) = recording {
bar = bar.child(
text(note)
@@ -1288,6 +1359,47 @@ fn statusbar(p: Paint, app: &App) -> El {
bar
}
/// The status bar's way into a pending update. Accent ink marks it as an action rather than a
/// daemon state; a staged update says it is ready instead of available.
fn update_chip(app: &App, p: Paint) -> Option<El> {
use crate::update::Phase;
let (label, version) = match (&app.update.phase, &app.update.available, &app.update.staged) {
(Phase::Staged, _, Some(staged)) => ("Update ready", staged.version.to_string()),
(Phase::Available | Phase::Failed, Some(available), _) => {
("Update available", available.version.to_string())
}
_ => return None,
};
Some(
el().key("update-chip")
.role("button")
.label(format!("{label}, version {version}"))
.focusable(true)
.h(20.0)
.px(8.0)
.gap(6.0)
.center_y()
.radius(radius::SM)
.fill(p.accent.alpha(0.14))
.border(p.hair, p.accent.alpha(0.32))
.hover(p.accent.alpha(0.22))
.press(p.accent.alpha(0.3))
.on_press_tx(|app: &mut App, tx: &mut Tx| {
app.jump(Screen::Settings);
app.settings_tab = SettingsTab::Advanced;
tx.scroll_to("scroller", 0.0, 0.0);
})
.child(ui::dot(p.accent))
.child(
text(format!("{label} · {version}"))
.key("label")
.font(body(10.5))
.color(p.accent)
.a11y_hidden(),
),
)
}
/// What the back arrow says it returns to.
fn back_label(screen: Screen) -> &'static str {
match screen {
+30
View File
@@ -23,6 +23,7 @@ mod screens;
mod settings;
mod theme;
mod ui;
mod update;
/// Print to the shell that started this app, when there is one.
///
@@ -55,6 +56,20 @@ fn demo_recording(app: &mut app::App) {
fn main() {
attach_console();
// The update helper is this same exe in apply mode: no window and no single-instance lock.
if let Some(index) = std::env::args().position(|arg| arg == "--apply-update") {
let args: Vec<String> = std::env::args().skip(index + 1).collect();
update::run_apply(&args);
return;
}
if std::env::args().any(|arg| arg == "--version") {
println!("leaguerecorder {}", update::current_version());
return;
}
if std::env::args().any(|arg| arg == "--check-updates") {
check_updates();
return;
}
if std::env::args().any(|arg| arg == "--games") {
println!("{} timelines", crate::history::timeline_paths().len());
return;
@@ -232,6 +247,21 @@ fn fetch_ffmpeg() {
}
}
/// `--check-updates`: ask the release list whether a newer capsule exists, then print it.
fn check_updates() {
match update::check(&update::releases_url()) {
Ok(Some(available)) => println!(
"{} is available: {} ({})",
available.version, available.asset, available.url
),
Ok(None) => println!("up to date ({})", update::current_version()),
Err(e) => {
eprintln!("{e}");
std::process::exit(1);
}
}
}
/// `--probe`: bring the daemon up and print what it answers, then exit. A quick check that the
/// IPC client and the daemon agree without opening a window.
fn probe() {
+92
View File
@@ -930,6 +930,17 @@ fn captioned_field(
))
}
/// The first lines of a release note, enough to say what changed without turning the card
/// into a document.
fn notes_excerpt(notes: &str) -> String {
let mut text = notes.lines().take(6).collect::<Vec<_>>().join("\n");
if let Some((cut, _)) = text.char_indices().nth(700) {
text.truncate(cut);
text.push_str("...");
}
text
}
fn advanced(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
let status_row = |key: &str, label: &'static str, value: String| {
row()
@@ -951,7 +962,88 @@ fn advanced(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, conte
};
let recording = if app.status.is_recording { "yes" } else { "no" };
let mut update_rows = vec![
status_row("app-version", "Version", app.update.current.to_string()),
status_row("update-status", "Status", app.update.status_text()),
];
if let Some(available) = &app.update.available {
if let Some(published) = available.published.as_deref() {
let shown = chrono::DateTime::parse_from_rfc3339(published)
.map(|at| crate::format::relative_time(at.with_timezone(&chrono::Utc)))
.unwrap_or_else(|_| published.to_string());
update_rows.push(status_row("update-published", "Published", shown));
}
if !available.notes.trim().is_empty() {
update_rows.push(
row()
.key("update-notes")
.w_full()
.px(space::S3)
.py(space::S2)
.child(
text(notes_excerpt(&available.notes))
.key("notes")
.font(body(11.5))
.color(p.muted())
.w_full(),
),
);
}
}
if app.update.can_check() || app.update.can_download() || app.update.can_install() {
let mut actions = row()
.key("update-actions")
.w_full()
.gap(8.0)
.px(space::S3)
.py(space::S2)
.center_y();
if app.update.can_check() {
actions = actions.child(ui::button(
p,
"update-check",
"Check now",
false,
|app: &mut App| app.update.check(true),
));
}
if app.update.can_download() {
let available = app.update.available.as_ref();
let version = available
.map(|available| available.version.to_string())
.unwrap_or_default();
let size = available
.map(|available| format!(" ({})", crate::format::bytes(available.size)))
.unwrap_or_default();
actions = actions.child(ui::button(
p,
"update-download",
&format!("Download {version}{size}"),
true,
|app: &mut App| app.update.download(),
));
}
if app.update.can_install() {
actions = actions.child(ui::button_tx(
p,
"update-install",
"Restart and install",
true,
|app: &mut App, tx: &mut rune::Tx| app.install_update(tx),
));
}
actions = actions.child(ui::button(
p,
"update-folder",
"Open update folder",
false,
|_app: &mut App| crate::daemon::open_folder(&crate::update::updates_dir()),
));
update_rows.push(actions);
}
content
.child(ui::card(p, Some("Updates"), update_rows))
.child(ui::card(
p,
Some("Daemon"),
+1458
View File
File diff suppressed because it is too large. Load diff