feat: install found updates without waiting for a click

Where the app can replace itself (the portable exe and the AppImage), a check that finds a release now installs it and relaunches straight away. The .deb still only reports the update.
This commit is contained in:
tiennm99 committed 2026-10-27 15:15:27 +07:00
1 parent 3aaf963841
commit cf058a4a38
2 files changed
+13 -4

No files matched your search

+3 -2
View File
@@ -102,7 +102,8 @@ Grab `usage-monitor.exe` from the
Put it in a folder of its own that you can write to (e.g.
`%LOCALAPPDATA%\UsageMonitor\`) and run it. The app is portable: it keeps
`settings.json` next to the exe, so moving the folder keeps your settings. It
self-updates from the same Releases feed.
updates itself from the same Releases feed: when a check finds a new
release, it installs it and restarts on its own, with no click needed.
**First-run note:** the binary is unsigned, so SmartScreen will show
"Windows protected your PC". Click **More info** → **Run anyway**. Code
@@ -117,7 +118,7 @@ pick one:
- `usage-monitor_X.Y.Z_amd64.AppImage`: make it executable
(`chmod +x`) and run it. Like the Windows exe it is portable and keeps
`settings.json` next to the AppImage file, so give it a folder you can
write to. The AppImage self-updates in place. If you turned on "Start
write to. The AppImage updates itself in place, the same way. If you turned on "Start
at login" in v0.6.0 or earlier and the AppImage path contains a space,
turn it off and on again once: those releases wrote the path unquoted,
so the app never started at login.
+10 -2
View File
@@ -657,8 +657,9 @@ impl Runtime {
/// Blocking body of [`Self::check_for_updates`]. Only a check that got
/// an answer is stamped as the last check; a failed one leaves the
/// stamp alone and has the scheduler retry sooner.
fn run_update_check(&self) {
/// stamp alone and has the scheduler retry sooner. A release found where
/// the app can replace itself is installed straight away.
fn run_update_check(self: &Arc<Self>) {
let proxy = update::proxy_url(net::env_proxy().as_ref(), self.http.system_proxy());
let outcome = update::check(&self.ui.app, proxy);
let succeeded = outcome.is_ok();
@@ -700,6 +701,13 @@ impl Runtime {
succeeded,
});
self.refresh_shell(false);
let auto_apply = self.with_state(|s| {
s.update_status == UpdateStatus::Available && s.update_channel.can_apply()
});
if auto_apply {
log::info!("update found; installing it without waiting for a click");
self.apply_update();
}
}
/// Download and install the release the last check found on a worker