Updater: always install the newest published version (#740) #744

Closed
charles wants to merge 0 commits from fix-740-updater-always-latest into textchat
Owner

Closes #740

Cause

UpdateState::on_timer skipped the periodic check while an update was Downloading or Ready, and the button / in-call "Restart" / install-on-quit applied whatever had been downloaded without looking at the feed again. So when release B came out after A had been downloaded, A was installed, and B was offered right after the restart.

Fix (spec §4.5.1, new; §4.4, §5.1, §5.3, §7 updated)

  • fluxer-core (still no I/O): checks keep running while an update is Downloading or Ready. The last verified download is kept as UpdateState::staged.
    • A newer manifest replaces a download that is still running (the runtime cancels the old one).
    • If an update is already ready, the newer one downloads in the background and the button stays. If that download fails, the ready one stays.
    • Installing first checks the feed again (status Applying):
      • if a newer release exists, it is downloaded (the button shows progress) and installed without another check;
      • if there is nothing newer, the check fails (offline), or the newer download or its verification fails, the staged update is installed.
    • Clicking while a newer release downloads waits for it, and falls back to the staged one if it fails.
    • Never goes backwards: a manifest that is not newer than the build, the staged update or the running download is ignored.
    • New UpdateEvent::QuitDeadline.
  • apps/fluxer:
    • On quit, after Quitting, the runtime keeps handling only update events until the store decides. It waits at most QUIT_INSTALL_LIMIT (5 min), then sends QuitDeadline, which installs the staged update.
    • The AppImage installer calls sweep_superseded after each verified download. The dry-run installer drops older version folders too.
  • fluxer-platform: new sweep_superseded(target, newest) (shares its code with sweep_leftovers).
  • fluxer-ui / selectors: the button ("Update available") and the in-call confirmation, which names the newer version, stay visible while a newer release downloads to replace the ready one.
  • fluxer-devserver: new scenario newest (2026.0101.3).
  • Velopack (velopack 1.2.161, from the crate source): download_updates deletes the other *.nupkg / *.partial files only after the new package is verified and renamed into place. A failed download returns early and keeps the waiting package. get_update_pending_restart returns the newest local full package. Velopack never replaces a waiting package by itself (auto-apply is off). So no Windows-specific code was needed, and no new imports were added inside cfg blocks.

Verification

  • crates/fluxer-core/tests/update.rs: 14 new tests, covering:

    • pending A, then B published: B becomes pending;
    • apply with B published: B is downloaded, then installed;
    • the check fails: A is installed;
    • B's download or verification fails: A is installed;
    • older or equal manifests are ignored (also at install time);
    • a download in flight is replaced (and so is a user-started one);
    • clicking during the replacement;
    • quit waits, then the deadline installs A;
    • a blocked B is skipped;
    • a channel switch drops the staged update.

    The 4 existing apply tests now expect the re-check first. 16 of these tests fail against the old update.rs, run with stubs added only so they compile.

  • crates/fluxer-platform/tests/update_apply.rs: a_newer_download_removes_the_superseded_staging_folder.

  • apps/fluxer/tests/update_runtime.rs:

    • devserver_update_flows_from_check_to_ready is extended: newest is published while newer is ready, and the periodic check downloads it and replaces the ready one. Switching the feed back to the older version keeps the newest.
    • New: apply_installs_a_version_published_after_the_ready_one, quit_installs_a_version_published_after_the_ready_one, quit_installs_the_ready_version_when_the_newer_one_does_not_come (a stalled download, 500 ms limit).
  • crates/fluxer-ui/tests/update.rs: confirm_restart_modal_names_the_newer_release_downloading.

  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: all steps passed. No goldens changed.

Not verified

  • Windows/Velopack at runtime: the replacement and fallback behaviour comes from reading the crate source; VelopackInstaller code is unchanged. The Windows CI runner will compile and lint it.
  • A real AppImage swap after a replacement. The sweep is tested in a temp dir, and the swap itself is unchanged.

🤖 Generated with Claude Code

Closes #740 ## Cause `UpdateState::on_timer` skipped the periodic check while an update was `Downloading` or `Ready`, and the button / in-call "Restart" / install-on-quit applied whatever had been downloaded without looking at the feed again. So when release B came out after A had been downloaded, A was installed, and B was offered right after the restart. ## Fix (spec §4.5.1, new; §4.4, §5.1, §5.3, §7 updated) - **fluxer-core** (still no I/O): checks keep running while an update is `Downloading` or `Ready`. The last verified download is kept as `UpdateState::staged`. - A newer manifest replaces a download that is still running (the runtime cancels the old one). - If an update is already ready, the newer one downloads in the background and the button stays. If that download fails, the ready one stays. - Installing first checks the feed again (status `Applying`): - if a newer release exists, it is downloaded (the button shows progress) and installed without another check; - if there is nothing newer, the check fails (offline), or the newer download or its verification fails, the staged update is installed. - Clicking while a newer release downloads waits for it, and falls back to the staged one if it fails. - Never goes backwards: a manifest that is not newer than the build, the staged update or the running download is ignored. - New `UpdateEvent::QuitDeadline`. - **apps/fluxer**: - On quit, after `Quitting`, the runtime keeps handling only update events until the store decides. It waits at most `QUIT_INSTALL_LIMIT` (5 min), then sends `QuitDeadline`, which installs the staged update. - The AppImage installer calls `sweep_superseded` after each verified download. The dry-run installer drops older version folders too. - **fluxer-platform**: new `sweep_superseded(target, newest)` (shares its code with `sweep_leftovers`). - **fluxer-ui / selectors**: the button ("Update available") and the in-call confirmation, which names the newer version, stay visible while a newer release downloads to replace the ready one. - **fluxer-devserver**: new scenario `newest` (`2026.0101.3`). - **Velopack** (velopack 1.2.161, from the crate source): `download_updates` deletes the other `*.nupkg` / `*.partial` files only after the new package is verified and renamed into place. A failed download returns early and keeps the waiting package. `get_update_pending_restart` returns the newest local full package. Velopack never replaces a waiting package by itself (auto-apply is off). So no Windows-specific code was needed, and no new imports were added inside cfg blocks. ## Verification - `crates/fluxer-core/tests/update.rs`: 14 new tests, covering: - pending A, then B published: B becomes pending; - apply with B published: B is downloaded, then installed; - the check fails: A is installed; - B's download or verification fails: A is installed; - older or equal manifests are ignored (also at install time); - a download in flight is replaced (and so is a user-started one); - clicking during the replacement; - quit waits, then the deadline installs A; - a blocked B is skipped; - a channel switch drops the staged update. The 4 existing apply tests now expect the re-check first. 16 of these tests fail against the old `update.rs`, run with stubs added only so they compile. - `crates/fluxer-platform/tests/update_apply.rs`: `a_newer_download_removes_the_superseded_staging_folder`. - `apps/fluxer/tests/update_runtime.rs`: - `devserver_update_flows_from_check_to_ready` is extended: `newest` is published while `newer` is ready, and the periodic check downloads it and replaces the ready one. Switching the feed back to the older version keeps the newest. - New: `apply_installs_a_version_published_after_the_ready_one`, `quit_installs_a_version_published_after_the_ready_one`, `quit_installs_the_ready_version_when_the_newer_one_does_not_come` (a stalled download, 500 ms limit). - `crates/fluxer-ui/tests/update.rs`: `confirm_restart_modal_names_the_newer_release_downloading`. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: all steps passed. No goldens changed. ## Not verified - Windows/Velopack at runtime: the replacement and fallback behaviour comes from reading the crate source; `VelopackInstaller` code is unchanged. The Windows CI runner will compile and lint it. - A real AppImage swap after a replacement. The sweep is tested in a temp dir, and the swap itself is unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The updater stopped checking while an update was downloading or ready, and
installed whatever it had downloaded, so a release published after it was
offered again right after the restart.

- fluxer-core: checks go on while Downloading/Ready; a newer release replaces
  a download in flight, and downloads in the background while the verified
  one (UpdateState::staged) stays installable. Installing (button, in-call
  Restart, quit) checks the feed again first; a newer release is downloaded
  and installed instead, and the staged update is installed when that check
  or download fails. Manifests not newer than the build, the staged update or
  the running download are ignored. New UpdateEvent::QuitDeadline.
- apps/fluxer: on quit the runtime handles the updater's events until the
  store decides, at most QUIT_INSTALL_LIMIT (5 min), then QuitDeadline.
- fluxer-platform: sweep_superseded removes staging folders older than a
  newly verified download; the AppImage installer calls it.
- fluxer-ui / selectors: the button and the in-call confirmation stay while a
  newer release downloads to replace the ready one.
- fluxer-devserver: scenario `newest` (2026.0101.3).
- Spec §4.4, §4.5.1 (new), §5.1, §5.3, §7 updated.

Refs #740

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Independent review of #744 (updater: always install the newest release)

I read the issue, the PR description, the spec changes and the diff without context, then ran the gate in a fresh worktree (756a7257).

Verdict: changes requested. The store's state machine is mostly sound. I found no state with no way out, no way to apply twice, no check → download loop, and no lost or doubled timers. The problems are elsewhere: the store and the installers can disagree about which file gets installed, Windows cannot replace a running download, and the new 5-minute wait on quit can hang the process and let two processes work on the same staging folder at once.

Blocking

B1. Windows: replacing a download in flight fails, and the abandoned download can delete the staged package.
Files: apps/fluxer/src/update_rt.rs:513-541, crates/fluxer-platform/src/update/velopack.rs:212-256.
CancelToken only stops waiting. The velopack-download thread keeps running download_updates, which holds Velopack's packages lock (try_get_exclusive_lock, non-blocking, velopack 1.2.161 locator.rs:337).

  • The PR adds a new path: a newer manifest replaces a running download. On Windows the replacement's download_updates fails at once because the lock is held.
    • Background download, A staged: you get Ready(A), retried 2 h later.
    • User-started download, nothing staged: the user sees a Failed error modal.
  • When the abandoned download later finishes, it deletes every other *.nupkg, including A's. VelopackInstaller.state still points at A, so apply_on_exit(A) returns FileNotFound and nothing is installed.
  • The same thing happens after QuitDeadline: B is cancelled while A is applied. If B finishes during the few seconds of shutdown, A's package is gone.

Nothing wrong gets installed, but "no Windows-specific code was needed" does not hold.
Fix: keep the join handle of the abandoned thread and wait for it before starting another download (or before apply). Alternatively, never cancel a Velopack download and let the core wait for it.

B2. The installer installs the last download that finished, not the one the store chose.
Files: apps/fluxer/src/update_rt.rs:291-298 (AppImage), crates/fluxer-core/src/update.rs:712-724.

  • AppImageInstaller::download sets self.staged and runs sweep_superseded whenever a download finishes. The runtime drops the event for a cancelled or superseded download, but the installer state and the deleted folder stay.
  • take_manifest's UpToDate branch sets Ready(staged A) while B is still Downloading and pushes no CancelDownload. Two ways to get there: the feed moves back to A (a pulled nightly), or a transient 404 / Ok(None) during a check that runs while a slow B downloads (2 h interval, or a 15 min backoff).
    • B then finishes: installer.staged = B and A's folder is swept.
    • The store says A is staged. The next install (offline re-check, or QuitDeadline) runs apply_staged, and the installer swaps in B, the release the feed withdrew.
  • The cancel check in Downloader::download is only in the chunk loop. A cancel that arrives during hashing still renames the file, sets staged and sweeps. With bad ordering (a late older download finishing after a newer one), staged points to a file the newer download's sweep removed, and you get ApplyFailed: missing.

Fix:

  1. Push CancelDownload in the UpToDate branch when Downloading.
  2. Have the installer check its cancel token before it publishes staged and sweeps.
  3. Preferably make UpdateCommand::Apply carry the version, and have the installer apply exactly that version's file (fail if it is absent), so the store's decision is what runs.

Missing test: a manifest that is up to date (or Ok(None)) while B downloads with A staged. Today it is covered only for Ready.

B3. The 5-minute wait on quit: Ctrl-C cannot stop it, there is no single-instance guard, and the bound is too long.
Files: apps/fluxer/src/runtime.rs:112, :866-870, :964-985, apps/fluxer/src/main.rs:292.

  • Ctrl-C. supervise catches the first Ctrl-C and stops listening. Tokio keeps its SIGINT handler installed, so every later Ctrl-C does nothing. A terminal user then waits up to 5 min (one re-check can already take up to 15 s connect + 60 s read; UpdateHttp has no total timeout) with no way out short of SIGKILL.
  • A second instance. There is no single-instance lock. Close the window and start the app again a minute later, and the old process is still alive with no window, downloading B. 10 s later the new process downloads B into the same .flaxative-update-B/…part, both appending.
    • Most of the time verification fails and the fallback or nothing is installed.
    • In the worst case, P2 opened the .part before P1 verified and renamed it. P2's late appends then land on the inode P1 is about to rename over the AppImage, so a verified file is altered after verification.
    • P1 also swaps the AppImage under the running P2 (harmless on Linux).
    • On Windows, Velopack's Update.exe applies into current\ while P2 runs from it. I did not verify what Update.exe does then, because it is not in the crate.
  • SIGTERM, logout, shutdown. There is no handler, so the process dies at once. That is safe: the .part / final file stays and is resumed or reused next run. It only means the quit-time install does not happen.

Fix:

  • Cap the wait at about 30 s: about 10 s for the re-check, and the rest only for a download that can plausibly finish.
  • Treat a second Ctrl-C or SIGTERM as QuitDeadline.
  • Take an exclusive lock (flock / named mutex) on the staging folder or the process before downloading or applying, or skip the install on quit when another instance holds it.

Minor

  • m1. A user who closed the window gets the app back. update.rs:514-518, 519-529. Sequence: click "Restart to update" (or "Restart" in a call), so Applying{relaunch:true} waits for its re-check; then close the window. Quitting does nothing because installable() is false in Applying, so relaunch:true survives and the app restarts after the user quit. (A Downloading + staged wait is switched to false by Quitting, which is the right behaviour.)
  • m2. No limit and no cancel for the re-check after the button. update.rs:1038-1046. The re-check before a click-install has no deadline beyond the HTTP timeouts. If it finds B, the user must wait for the whole download: the button does nothing on Downloading{user_started:true}, and there is no "install the ready one now". Consider the same deadline as on quit.
  • m3. A failed manual check hides the staged update (pre-existing, now visible). update.rs:622-629, 951-964. "Check for updates" fails while Ready, so status becomes Failed{release: None}, and Dismiss gives Idle while staged is still Some. installable() is false, so quitting does not install the verified update, and the button stays hidden until the next periodic check (2 h). Same for a quit during Checking{manual}. Restoring Ready(staged) on dismiss is one line.
  • m4. A non-automatic Available hides the staged update. update.rs:761-763. With automatic off (or a newer release that is Manual), a newer manifest turns Ready(A) into Available(B), which hides A.
  • m5. Spec wording. The spec says "the late end of the cancelled download is ignored". That is true for the store only; see B1 and B2.

Answers to the review checklist

  1. State machine. States are Disabled / Idle / Checking / UpToDate / Available / Downloading (±staged) / Ready / Applying (waiting for the check, or not) / Failed, plus QuitDeadline. No trap state, no double apply, never older than the running build or staged in the store. Timers: every path schedules exactly one live next_check. Stale ids are ignored, and the begin-apply check that takes over a background check's reply is handled. The problem is store/installer divergence (B1, B2).
  2. Quit wait. See B3. With nothing staged, quitting does not touch the network (installable() is false) and quits at once. With a staged update, every quit makes one manifest fetch.
  3. Fallbacks. All three are present in the store and tested: a failed check, a failed or unverified newer download, and nothing staged. On Windows, B1 can turn "install A" into "install nothing".
  4. sweep_superseded. It only touches .flaxative-update-<parsed version> directories next to the AppImage. DirEntry::file_type does not follow symlinks, remove_dir_all does not follow inner symlinks, and the version is a numeric ReleaseVersion, not text taken from the manifest. It cannot reach the running AppImage or anything outside. It can delete the folder the store still regards as staged (B2).
  5. Velopack. The PR's description is accurate. download_updates collects *.nupkg/*.partial before downloading and deletes them only after verifying and renaming. It returns early on failure and leaves the .partial. get_update_pending_restart returns the newest full package only if it is newer than the installed version. What it omits is the non-blocking global lock download_updates takes, which is the cause of B1.
  6. Tests. The core and runtime tests assert outcomes (which version Apply installs and installed), which is good. The runtime FakeInstaller has the same "last finished wins" semantics and ignores cancel, so B1 and B2 cannot show up. Untested: UpToDate/Ok(None) during a replacement, a cancelled download finishing late, Ctrl-C during the quit wait, and two processes.
  7. Gate. See below.

Gate

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a fresh worktree of 756a7257: all steps passed, exit 0. Steps: ffmpeg, fmt, clippy, deny, core-isolation, parity, test, vendored-tests, screenshot-tests; livekit-interop skipped because FLUXER_LIVEKIT_TESTS is not 1. textchat_session_end_to_end passed. (A first run was killed from outside the process during test; it had no failures up to then. The full rerun was green.) The gate is not a blocker.

Verdict: changes requested (B1, B2, B3).

## Independent review of #744 (updater: always install the newest release) I read the issue, the PR description, the spec changes and the diff without context, then ran the gate in a fresh worktree (`756a7257`). **Verdict: changes requested.** The store's state machine is mostly sound. I found no state with no way out, no way to apply twice, no check → download loop, and no lost or doubled timers. The problems are elsewhere: the store and the installers can disagree about *which file* gets installed, Windows cannot replace a running download, and the new 5-minute wait on quit can hang the process and let two processes work on the same staging folder at once. ### Blocking **B1. Windows: replacing a download in flight fails, and the abandoned download can delete the staged package.** Files: `apps/fluxer/src/update_rt.rs:513-541`, `crates/fluxer-platform/src/update/velopack.rs:212-256`. `CancelToken` only stops *waiting*. The `velopack-download` thread keeps running `download_updates`, which holds Velopack's packages lock (`try_get_exclusive_lock`, **non-blocking**, velopack 1.2.161 `locator.rs:337`). - The PR adds a new path: a newer manifest replaces a running download. On Windows the replacement's `download_updates` fails at once because the lock is held. - Background download, A staged: you get `Ready(A)`, retried 2 h later. - User-started download, nothing staged: the user sees a `Failed` error modal. - When the abandoned download later finishes, it deletes every other `*.nupkg`, including A's. `VelopackInstaller.state` still points at A, so `apply_on_exit(A)` returns `FileNotFound` and nothing is installed. - The same thing happens after `QuitDeadline`: B is cancelled while A is applied. If B finishes during the few seconds of shutdown, A's package is gone. Nothing wrong gets installed, but "no Windows-specific code was needed" does not hold. Fix: keep the join handle of the abandoned thread and wait for it before starting another download (or before `apply`). Alternatively, never cancel a Velopack download and let the core wait for it. **B2. The installer installs the last download that *finished*, not the one the store chose.** Files: `apps/fluxer/src/update_rt.rs:291-298` (AppImage), `crates/fluxer-core/src/update.rs:712-724`. - `AppImageInstaller::download` sets `self.staged` and runs `sweep_superseded` whenever a download finishes. The runtime drops the event for a cancelled or superseded download, but the installer state and the deleted folder stay. - `take_manifest`'s `UpToDate` branch sets `Ready(staged A)` while B is still `Downloading` and pushes no `CancelDownload`. Two ways to get there: the feed moves back to A (a pulled nightly), or a transient `404` / `Ok(None)` during a check that runs while a slow B downloads (2 h interval, or a 15 min backoff). - B then finishes: `installer.staged = B` and A's folder is swept. - The store says A is staged. The next install (offline re-check, or `QuitDeadline`) runs `apply_staged`, and the installer swaps in **B, the release the feed withdrew**. - The cancel check in `Downloader::download` is only in the chunk loop. A cancel that arrives during hashing still renames the file, sets `staged` and sweeps. With bad ordering (a late older download finishing after a newer one), `staged` points to a file the newer download's sweep removed, and you get `ApplyFailed: missing`. Fix: 1. Push `CancelDownload` in the `UpToDate` branch when `Downloading`. 2. Have the installer check its cancel token before it publishes `staged` and sweeps. 3. Preferably make `UpdateCommand::Apply` carry the version, and have the installer apply exactly that version's file (fail if it is absent), so the store's decision is what runs. Missing test: a manifest that is up to date (or `Ok(None)`) while B downloads with A staged. Today it is covered only for `Ready`. **B3. The 5-minute wait on quit: Ctrl-C cannot stop it, there is no single-instance guard, and the bound is too long.** Files: `apps/fluxer/src/runtime.rs:112`, `:866-870`, `:964-985`, `apps/fluxer/src/main.rs:292`. - **Ctrl-C.** `supervise` catches the first Ctrl-C and stops listening. Tokio keeps its SIGINT handler installed, so every later Ctrl-C does nothing. A terminal user then waits up to 5 min (one re-check can already take up to 15 s connect + 60 s read; `UpdateHttp` has no total timeout) with no way out short of SIGKILL. - **A second instance.** There is no single-instance lock. Close the window and start the app again a minute later, and the old process is still alive with no window, downloading B. 10 s later the new process downloads B into the **same** `.flaxative-update-B/…part`, both appending. - Most of the time verification fails and the fallback or nothing is installed. - In the worst case, P2 opened the `.part` before P1 verified and renamed it. P2's late appends then land on the inode P1 is about to rename over the AppImage, so a verified file is altered after verification. - P1 also swaps the AppImage under the running P2 (harmless on Linux). - On Windows, Velopack's `Update.exe` applies into `current\` while P2 runs from it. I did not verify what `Update.exe` does then, because it is not in the crate. - **SIGTERM, logout, shutdown.** There is no handler, so the process dies at once. That is safe: the `.part` / final file stays and is resumed or reused next run. It only means the quit-time install does not happen. Fix: - Cap the wait at about **30 s**: about 10 s for the re-check, and the rest only for a download that can plausibly finish. - Treat a second Ctrl-C or SIGTERM as `QuitDeadline`. - Take an exclusive lock (flock / named mutex) on the staging folder or the process before downloading or applying, or skip the install on quit when another instance holds it. ### Minor - **m1. A user who closed the window gets the app back.** `update.rs:514-518, 519-529`. Sequence: click "Restart to update" (or "Restart" in a call), so `Applying{relaunch:true}` waits for its re-check; then close the window. `Quitting` does nothing because `installable()` is false in `Applying`, so `relaunch:true` survives and the app restarts after the user quit. (A `Downloading` + staged wait is switched to `false` by `Quitting`, which is the right behaviour.) - **m2. No limit and no cancel for the re-check after the button.** `update.rs:1038-1046`. The re-check before a click-install has no deadline beyond the HTTP timeouts. If it finds B, the user must wait for the whole download: the button does nothing on `Downloading{user_started:true}`, and there is no "install the ready one now". Consider the same deadline as on quit. - **m3. A failed manual check hides the staged update (pre-existing, now visible).** `update.rs:622-629, 951-964`. "Check for updates" fails while `Ready`, so status becomes `Failed{release: None}`, and Dismiss gives `Idle` while `staged` is still `Some`. `installable()` is false, so quitting does not install the verified update, and the button stays hidden until the next periodic check (2 h). Same for a quit during `Checking{manual}`. Restoring `Ready(staged)` on dismiss is one line. - **m4. A non-automatic `Available` hides the staged update.** `update.rs:761-763`. With `automatic` off (or a newer release that is `Manual`), a newer manifest turns `Ready(A)` into `Available(B)`, which hides A. - **m5. Spec wording.** The spec says "the late end of the cancelled download is ignored". That is true for the store only; see B1 and B2. ### Answers to the review checklist 1. **State machine.** States are Disabled / Idle / Checking / UpToDate / Available / Downloading (±staged) / Ready / Applying (waiting for the check, or not) / Failed, plus `QuitDeadline`. No trap state, no double apply, never older than the running build or `staged` *in the store*. Timers: every path schedules exactly one live `next_check`. Stale ids are ignored, and the begin-apply check that takes over a background check's reply is handled. The problem is store/installer divergence (B1, B2). 2. **Quit wait.** See B3. With nothing staged, quitting does not touch the network (`installable()` is false) and quits at once. With a staged update, every quit makes one manifest fetch. 3. **Fallbacks.** All three are present in the store and tested: a failed check, a failed or unverified newer download, and nothing staged. On Windows, B1 can turn "install A" into "install nothing". 4. **`sweep_superseded`.** It only touches `.flaxative-update-<parsed version>` **directories** next to the AppImage. `DirEntry::file_type` does not follow symlinks, `remove_dir_all` does not follow inner symlinks, and the version is a numeric `ReleaseVersion`, not text taken from the manifest. It cannot reach the running AppImage or anything outside. It **can** delete the folder the store still regards as staged (B2). 5. **Velopack.** The PR's description is accurate. `download_updates` collects `*.nupkg`/`*.partial` before downloading and deletes them only after verifying and renaming. It returns early on failure and leaves the `.partial`. `get_update_pending_restart` returns the newest full package only if it is newer than the installed version. What it omits is the non-blocking global lock `download_updates` takes, which is the cause of B1. 6. **Tests.** The core and runtime tests assert outcomes (which version `Apply` installs and `installed`), which is good. The runtime `FakeInstaller` has the same "last finished wins" semantics and ignores cancel, so B1 and B2 cannot show up. Untested: `UpToDate`/`Ok(None)` during a replacement, a cancelled download finishing late, Ctrl-C during the quit wait, and two processes. 7. **Gate.** See below. ### Gate `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a fresh worktree of `756a7257`: **all steps passed**, exit 0. Steps: ffmpeg, fmt, clippy, deny, core-isolation, parity, test, vendored-tests, screenshot-tests; livekit-interop skipped because `FLUXER_LIVEKIT_TESTS` is not 1. `textchat_session_end_to_end` passed. (A first run was killed from outside the process during `test`; it had no failures up to then. The full rerun was green.) The gate is not a blocker. **Verdict: changes requested** (B1, B2, B3).
- One source of truth: UpdateCommand::Apply carries the version; installers
  record downloads by version only when finished and not cancelled, install
  exactly the version asked for or fail, and delete other downloads only on
  the new UpdateCommand::Keep (sweep_except), sent once the store settled.
- A running download is never replaced or cancelled for a newer release; the
  feed is looked at again when it ends. Not-newer or missing manifests change
  nothing; an older one marks the running download withdrawn (not staged).
- Quit: no check, no new download; the staged update installs at once, or
  after a running newer download, at most 30 s after the quit began, or at
  once on a second Ctrl-C / SIGTERM (QuitInterrupter in tests).
- Manifest requests have a 10 s total limit; the button's newer download can
  be stopped to install the staged update.
- UpdateLock: an exclusive file lock in the installer's folder before any
  download, sweep or install; another process gets UpdateError::Busy, silent.
- Velopack: a cancelled download returns at once with its result dropped,
  the next one waits for it; prepare re-reads the pending package.
- m1 no relaunch after the window closed; m3/m4 keep the staged update shown.
- Spec §4.5.1, §5.1, §5.3, §7 and READMEs match.

Refs #740

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Answer to the review (commit 5897c7e9, origin/textchat merged in first)

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: all steps passed. I went with simplifying the design rather than patching each hole one by one.

Blocking findings

B1 (Windows: a cancelled Velopack download keeps running).

  • A running download is no longer replaced or cancelled when a newer release appears. The store remembers the newer release and checks the feed again once the running download ends. That removes the code path where B1 started.
  • Only a cancel the user asks for remains: a channel switch, the "stop" click on the button (m2) and the quit deadline. For those, VelopackUpdater::download returns Cancelled at once and drops whatever Velopack finishes with. The next download first waits for the abandoned thread to end (IN_FLIGHT), so it cannot run into Velopack's non-blocking packages lock. Process exit is never held up by it.
  • VelopackInstaller records a download only if it was not cancelled. prepare re-reads what Velopack actually holds (get_update_pending_restart) and accepts only the version the store asked for.
  • If an abandoned download still finishes and deletes the waiting package, the install fails rather than installing something else. There is one remaining window: Velopack's thread finishing in the seconds between apply_on_exit and the process exiting. That is untestable here and described in spec §5.3.
  • Tests: a_cancelled_download_finishing_late_is_never_installed (the real downloader, cancelled while hashing, both through the Downloader and through the installer); the core test a_running_download_is_never_replaced_and_the_newer_one_follows. The Windows code itself cannot be built or run here.

B2 (the installer installed the last download that finished, not the one the store chose).

  • UpdateCommand::Apply { version, relaunch } now names the version. Every installer installs exactly that version or returns an error.
  • Installers record downloads by version, and only when a download finished and was not cancelled. The cancel token is also checked after hashing, before the rename in Downloader.
  • Installers no longer sweep after a download. The store sends UpdateCommand::Keep { version } once it has settled on the new staged update, and only then are the other folders removed (sweep_except).
  • A manifest that is not newer, or Ok(None), while a download runs changes nothing.
  • A manifest older than the running download (a withdrawn release) marks it. When it finishes it is not staged: the store sends Keep(staged) and every install path installs the staged update.
  • Tests:
    • core: not_newer_or_missing_manifests_while_a_newer_download_runs_change_nothing, a_release_withdrawn_while_it_downloads_is_never_installed;
    • runtime: a_release_withdrawn_while_it_downloads_is_never_installed;
    • real AppImage installer: the_appimage_installer_installs_exactly_the_version_asked_for (only B on disk: Apply(A) fails and leaves the AppImage untouched);
    • platform: keeping_one_update_removes_every_other_staging_folder.

B3 (the 5-minute windowless wait on quit, Ctrl-C, two processes).

  • Quitting no longer checks the feed or starts a download. The staged update is installed at once.
  • Only a newer download that was already running is waited for, at most until QUIT_INSTALL_LIMIT = 30 s after the quit began. A second Ctrl-C or SIGTERM ends the wait at once and installs the staged update. The runtime listens for those signals during that wait. Handle::quit_interrupter() does the same in tests.
  • With nothing staged, quitting fetches nothing.
  • Every manifest request now has a 10 s total time limit (MANIFEST_TIMEOUT).
  • New UpdateLock: an exclusive file lock on .flaxative-update.lock in the installer's folder (next to the AppImage; for Velopack, <cache>/updates). It is taken before any download to the staging folder, before the start-up sweep and before any install. The OS releases it when the process ends, crash included. A process that cannot get it gets UpdateError::Busy, which the store handles silently.
  • Tests:
    • quit_with_a_newer_release_published_installs_the_ready_one_at_once (no check, no download, under 5 s);
    • quit_waits_for_a_running_newer_download_and_installs_it;
    • quit_installs_the_ready_version_when_the_newer_one_does_not_come_in_time;
    • insisting_on_quitting_ends_the_wait_at_once;
    • a_second_runtime_on_the_same_staging_folder_leaves_updating_to_the_first;
    • a_slow_manifest_times_out_in_all;
    • the lock unit test one_holder_at_a_time_and_released_on_drop;
    • core: quitting_installs_the_ready_update_without_checking_or_downloading, quitting_waits_only_for_a_newer_download_already_running, another_copy_updating_is_silent.

Minor findings

  • m1 (closing the window during the button's re-check relaunched the app): fixed. Quitting during the button's re-check, or while waiting for its download, installs without relaunching. Test: closing_the_window_during_the_buttons_recheck_installs_without_relaunch.
  • m2 (no limit and no cancel for the re-check after a click): fixed. The button's re-check has the 10 s limit. While the newer release downloads, the button stays enabled ("Updating… N% — click to install {version} now"), and a click stops the download and installs the staged update. Test: the_user_can_stop_the_newer_download_and_install_the_ready_update.
  • m3 (a failed manual check hid the staged update): fixed. Dismissing the error returns to Ready(staged), and quitting while the error is shown still installs the staged update. Test: a_failed_manual_check_does_not_hide_the_ready_update.
  • m4 (a non-automatic newer release hid the staged update): fixed. A newer release that is not downloaded in the background keeps Ready(staged) visible; the button then checks again and fetches the newer one. Test: a_newer_release_not_downloaded_in_the_background_keeps_the_ready_update_shown.
  • m5 (spec wording): fixed. Spec §4.5.1 is rewritten to match the code, and §5.1, §5.3 (Velopack's lock and abandoned downloads) and §7 are updated. The READMEs too.

Not covered

Windows/Velopack cannot be compiled or run here (ring's C build needs the MSVC SDK). The Windows CI run is the first build of VelopackInstaller and the Velopack changes in fluxer-platform.

🤖 Generated with Claude Code

## Answer to the review (commit 5897c7e9, `origin/textchat` merged in first) `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: all steps passed. I went with simplifying the design rather than patching each hole one by one. ### Blocking findings **B1 (Windows: a cancelled Velopack download keeps running).** - A running download is no longer replaced or cancelled when a newer release appears. The store remembers the newer release and checks the feed again once the running download ends. That removes the code path where B1 started. - Only a cancel the user asks for remains: a channel switch, the "stop" click on the button (m2) and the quit deadline. For those, `VelopackUpdater::download` returns `Cancelled` at once and drops whatever Velopack finishes with. The next download first waits for the abandoned thread to end (`IN_FLIGHT`), so it cannot run into Velopack's non-blocking packages lock. Process exit is never held up by it. - `VelopackInstaller` records a download only if it was not cancelled. `prepare` re-reads what Velopack actually holds (`get_update_pending_restart`) and accepts only the version the store asked for. - If an abandoned download still finishes and deletes the waiting package, the install fails rather than installing something else. There is one remaining window: Velopack's thread finishing in the seconds between `apply_on_exit` and the process exiting. That is untestable here and described in spec §5.3. - Tests: `a_cancelled_download_finishing_late_is_never_installed` (the real downloader, cancelled while hashing, both through the `Downloader` and through the installer); the core test `a_running_download_is_never_replaced_and_the_newer_one_follows`. The Windows code itself cannot be built or run here. **B2 (the installer installed the last download that finished, not the one the store chose).** - `UpdateCommand::Apply { version, relaunch }` now names the version. Every installer installs exactly that version or returns an error. - Installers record downloads by version, and only when a download finished and was not cancelled. The cancel token is also checked after hashing, before the rename in `Downloader`. - Installers no longer sweep after a download. The store sends `UpdateCommand::Keep { version }` once it has settled on the new staged update, and only then are the other folders removed (`sweep_except`). - A manifest that is not newer, or `Ok(None)`, while a download runs changes nothing. - A manifest older than the running download (a withdrawn release) marks it. When it finishes it is not staged: the store sends `Keep(staged)` and every install path installs the staged update. - Tests: - core: `not_newer_or_missing_manifests_while_a_newer_download_runs_change_nothing`, `a_release_withdrawn_while_it_downloads_is_never_installed`; - runtime: `a_release_withdrawn_while_it_downloads_is_never_installed`; - real AppImage installer: `the_appimage_installer_installs_exactly_the_version_asked_for` (only B on disk: `Apply(A)` fails and leaves the AppImage untouched); - platform: `keeping_one_update_removes_every_other_staging_folder`. **B3 (the 5-minute windowless wait on quit, Ctrl-C, two processes).** - Quitting no longer checks the feed or starts a download. The staged update is installed at once. - Only a newer download that was already running is waited for, at most until `QUIT_INSTALL_LIMIT` = 30 s after the quit began. A second Ctrl-C or SIGTERM ends the wait at once and installs the staged update. The runtime listens for those signals during that wait. `Handle::quit_interrupter()` does the same in tests. - With nothing staged, quitting fetches nothing. - Every manifest request now has a 10 s total time limit (`MANIFEST_TIMEOUT`). - New `UpdateLock`: an exclusive file lock on `.flaxative-update.lock` in the installer's folder (next to the AppImage; for Velopack, `<cache>/updates`). It is taken before any download to the staging folder, before the start-up sweep and before any install. The OS releases it when the process ends, crash included. A process that cannot get it gets `UpdateError::Busy`, which the store handles silently. - Tests: - `quit_with_a_newer_release_published_installs_the_ready_one_at_once` (no check, no download, under 5 s); - `quit_waits_for_a_running_newer_download_and_installs_it`; - `quit_installs_the_ready_version_when_the_newer_one_does_not_come_in_time`; - `insisting_on_quitting_ends_the_wait_at_once`; - `a_second_runtime_on_the_same_staging_folder_leaves_updating_to_the_first`; - `a_slow_manifest_times_out_in_all`; - the lock unit test `one_holder_at_a_time_and_released_on_drop`; - core: `quitting_installs_the_ready_update_without_checking_or_downloading`, `quitting_waits_only_for_a_newer_download_already_running`, `another_copy_updating_is_silent`. ### Minor findings - **m1 (closing the window during the button's re-check relaunched the app):** fixed. `Quitting` during the button's re-check, or while waiting for its download, installs without relaunching. Test: `closing_the_window_during_the_buttons_recheck_installs_without_relaunch`. - **m2 (no limit and no cancel for the re-check after a click):** fixed. The button's re-check has the 10 s limit. While the newer release downloads, the button stays enabled ("Updating… N% — click to install {version} now"), and a click stops the download and installs the staged update. Test: `the_user_can_stop_the_newer_download_and_install_the_ready_update`. - **m3 (a failed manual check hid the staged update):** fixed. Dismissing the error returns to `Ready(staged)`, and quitting while the error is shown still installs the staged update. Test: `a_failed_manual_check_does_not_hide_the_ready_update`. - **m4 (a non-automatic newer release hid the staged update):** fixed. A newer release that is not downloaded in the background keeps `Ready(staged)` visible; the button then checks again and fetches the newer one. Test: `a_newer_release_not_downloaded_in_the_background_keeps_the_ready_update_shown`. - **m5 (spec wording):** fixed. Spec §4.5.1 is rewritten to match the code, and §5.1, §5.3 (Velopack's lock and abandoned downloads) and §7 are updated. The READMEs too. ### Not covered Windows/Velopack cannot be compiled or run here (ring's C build needs the MSVC SDK). The Windows CI run is the first build of `VelopackInstaller` and the Velopack changes in `fluxer-platform`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Re-review of #744 at 5897c7e9 (cold, fresh worktree)

I read the core, update_rt.rs, runtime.rs, fluxer-platform (lock.rs, velopack.rs, download.rs, http.rs, sweep.rs), the tests and the spec at 5897c7e9. I checked the answer in comment 7849 against the code rather than taking it on trust. I could not compile the cfg(windows) code; it was read by hand. The tokio and velopack behaviour cited below comes from their crate sources in the cargo registry (tokio 1.54, velopack 1.2.161).

Verdict: changes requested. On Linux, B2 and B3 are fixed, and the core state machine is now clean. One blocking problem is left. It is Windows-only and in code that has never been compiled: a Velopack download that is not cancelled, or the new IN_FLIGHT wait, keeps the process alive after the window closes. That can also make Velopack give up on the install.

Blocking

W1. Windows: a quit can leave a windowless process that does not exit, and the install on quit can fail with it.
Where:

  • crates/fluxer-platform/src/update/velopack.rs:229-233 (the IN_FLIGHT wait);
  • apps/fluxer/src/update_rt.rs:600-633 (VelopackInstaller::download runs on spawn_blocking);
  • crates/fluxer-core/src/update.rs:581-601 (on_quitting);
  • apps/fluxer/src/main.rs:77 and :176 (main's tokio runtime is dropped at the end of main).

Why the process stays alive: dropping a tokio Runtime waits without limit for every running spawn_blocking task (tokio 1.54 runtime/blocking/pool.rs:343, BlockingPool::drop → shutdown(None)). VelopackInstaller::download is such a task. Only its cancel token ends it early, and two paths never get there.

  1. The IN_FLIGHT wait ignores cancel. let _ = abandoned.recv(); blocks until the abandoned Velopack thread ends. Velopack's HttpSource is built without options, and ureq 3 then sets no timeout (velopack download.rs:95-102). A download that stalls (Wi-Fi change, sleep, dead TCP connection) can therefore block forever.
    • Scenario: channel switch while B downloads, so B is abandoned. The next download C (the new channel's check) blocks in recv(), and the UI shows "Downloading 0%" for as long as B lasts.
    • Scenario: B is abandoned by the skip click, then the next check starts C: same.
    • While blocked, nothing can end C. CancelDownload and QuitDeadline set a token that nobody reads until recv() returns.
    • On quit with something staged: after 30 s, QuitDeadline sends Apply(A), and apply_on_exit starts Update.exe, which waits up to 60 s for the process to exit (velopack.rs doc). The process cannot exit while the blocking pool waits on recv(). After 60 s Update.exe gives up, so nothing is installed and a windowless process remains.
  2. Quit never cancels a download it does not wait for. on_quitting returns at once when nothing is staged, or with automatic off and nothing asked for. It sends no CancelDownload, and dropping UpdateRuntime cancels nothing. The Velopack poll loop therefore runs until the whole download finishes, and the closed app stays in the process list until then. On a stall, that is forever.
    • Concrete case: the first update's download is running and the user closes the window.
    • This was already true before #740. It contradicts "with nothing staged, quitting fetches nothing", and #744 adds case 1 on top.

Linux is not affected: AppImage downloads are async tasks, dropped with the runtime.

Fixes, smallest first:

  • (a) In the IN_FLIGHT wait, use recv_timeout(POLL) in a loop that also checks cancel and returns Cancelled.
  • (b) Have on_quitting (or the runtime's UpdateRuntime drop) cancel any download it is not going to wait for.
  • (c) End main with runtime.shutdown_timeout(…) so blocking tasks can never hold the process.

None of this has a test: there is no Windows build, and the FakeInstaller is async.

Minor

  • m1. prepare makes a blocking Velopack disk read on the async executor. Where: update_rt.rs:664-678. VelopackInstaller::prepare calls updater.pending() (get_update_pending_restart: lists packages and reads the nupkg manifests) from Executor::apply_update. That breaks VelopackUpdater's own rule ("Every call blocks … run it on a blocking task"). It is short, but it runs on a runtime worker.
  • m2. The answer's "every install path installs the staged update" does not hold for a withdrawn release on Windows. keep is a no-op for Velopack. When the withdrawn C finishes, download_updates has already deleted A's nupkg, so prepare(A) sees C and fails with "missing". Nothing wrong is installed, and the spec's §5.3 does say "otherwise the install fails". But the first install after a withdrawal fails once (Failed, Try again downloads A again). No test covers it.
  • m3. The admitted residual race is real and fairly likely after QuitDeadline, though safe. B is still downloading at 30 s and is abandoned. If it finishes during the ≤ ~10 s shutdown, download_updates deletes A's nupkg and also extracts B's Squirrel.exe over Update.exe. apply_on_exit(A) then returns FileNotFound, or Update.exe cannot find the package. Nothing is installed this time, and next run's pending() gives B instantly. Suggestions: log it; or, after QuitDeadline on Velopack, skip the install when an abandoned download is in flight rather than racing it.
  • m4. A process started right after an update skips the start-up sweep.
    • Linux: the old process still holds the UpdateLock while appimage::relaunch starts the new one. The lock lives in UpdateRuntime until run() ends, and the fd is O_CLOEXEC, so it is not inherited. The new process's start-up take_lock therefore fails ("another copy of the app is updating"), and sweep_leftovers is skipped for that run.
    • Updating is not disabled: the lock is retried lazily on the first download and install, by which time the old process has exited.
    • Harmless, but releasing the lock before relaunching (drop update's lock before installer.apply) would make the log honest.
  • m5. A second instance redownloads what the first installed. P1 is in its ≤30 s quit wait, P2 starts and gets Busy and settles silently. P1 then swaps the AppImage under P2. P2 finds the same release at its next check (2 h), downloads it again and swaps the same version over itself on quit. This wastes bandwidth only.
  • m6. A user's explicit request is silently dropped when another copy holds the lock. update.rs:988-993. Busy on a user-started download (a click on Available) settles to Idle with no message, and the button disappears. Showing "another copy of Flaxative is updating" for user-started actions would be kinder.
  • m7. Signals after the quit wait. insistence installs tokio's SIGINT and SIGTERM handlers, and they stay for the life of the process. After the wait ends, the rest of the shutdown (gateway ≤5 s, writes ≤5 s, install) ignores SIGINT and SIGTERM. The same holds for SIGINT from the first Ctrl-C (main.rs:292) or a window close onward. The remaining shutdown is bounded on Linux, so this matters only together with W1.

Your checks

(a) State machine. I re-walked it with Keep, withdrawn, look_again and Busy.

  • No dead end:
    • every Downloading ends through Downloaded / QuitDeadline / the skip click / a channel switch;
    • Applying ends through Apply or ApplyFailed;
    • Busy settles to Ready(staged) or Idle.
  • No double apply: apply_after_check and apply_after_download are take()n; the quit loop stops on exit_for_update or when nothing is waited for.
  • Timers: the look_again re-check and the before-install check each schedule a new next_check. The id they replace is ignored when it fires, so there is never more than one live timer and none is lost.
  • No loop: look_again is set only by a newer manifest, and one failure without look_again returns to rest. Busy makes no immediate retry.
  • Keep is only sent from on_downloaded, after staged changed. It goes before Apply, and Keep(None) only when nothing is staged, so it never sweeps the update about to be installed.
  • withdrawn applies only to a manifest (or UpToDate(Some)) below the running download. A 404 and "no asset for this platform" do not count, which is right.

(b) The old blocking findings.

  • B1 (Windows replacement). The core never replaces a running download, so the lock clash on replacement is gone. The cancel paths are left (channel switch, skip, QuitDeadline), and with them W1.
  • B2 (wrong file installed). I found no Linux scenario that still installs a file other than the one named:
    • Apply{version} resolves to downloads[version] and must be a file;
    • a cancel is checked after hashing (in Downloader) and again in the installer;
    • folders are removed only on Keep.
      On Windows the outcome is "fail, never install wrong" (m2, m3).
  • B3 (quit wait).
    • Quitting never checks the feed or downloads.
    • Nothing staged: no fetch and no wait in the runtime, but see W1 for Velopack.
    • The wait is bounded at 30 s; a second Ctrl-C or SIGTERM ends it (Unix; Windows ctrl_c).
    • Manifest requests have a 10 s total limit.
    • Two processes are guarded by UpdateLock.

(c) The lock.

  • Stale lock after a crash: no. flock / LockFileEx locks are released when the process dies; only an empty dotfile remains. Its name, .flaxative-update.lock, does not match the sweep's .flaxative-update- prefix, so the sweep never removes it.
  • Taken before the start-up sweep: yes (update_rt.rs:775).
  • Relaunch: the new process does not get the lock at start (m4), but takes it lazily later, so updating is not disabled.
  • Read-only folder: try_acquire errors and take_lock lets it proceed, which is fine because such an install is Manual with no lock_dir. A missing folder is created.
  • NFS without flock falls into the same "proceed" path.

(d) Signals. Nothing swallows Ctrl-C while the window is open or during the quit wait. After supervise breaks, and after the wait, SIGINT and SIGTERM are swallowed for the rest of a bounded shutdown (m7). The process can exit when the quit wait is not active on Linux. On Windows it cannot, while a Velopack download that was not cancelled is running (W1).

(e) Tests. FakeInstaller is now honest:

  • it records only by version;
  • a cancelled download ends late and is never recorded;
  • keep drops the others;
  • apply installs the version named;
  • it has a lock folder.

Every Linux blocking scenario has a test that asserts what was installed, including the real AppImageInstaller and Downloader: withdrawn, cancelled-late, exact version, quit at once, the quit wait and its deadline, insisting, two runtimes, a slow manifest. Not covered: the Windows paths (W1, m2, m3), and a test with no fake at all for a quit with nothing staged while a download runs.

Gate

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci at 5897c7e9: all steps passed, exit 0. Steps: ffmpeg, fmt, clippy, deny, core-isolation, parity, test, vendored-tests, screenshot-tests; livekit-interop skipped because FLUXER_LIVEKIT_TESTS is not 1. textchat_session_end_to_end passed on the first run. This is a Linux gate only. The cfg(windows) code (velopack.rs imp, VelopackInstaller) has not been compiled anywhere. I read it for type errors, cfg mistakes and unused imports and found none (VelopackUpdater: Clone and PendingUpdate::version() exist; fluxer_platform::{Paths, APP_NAME} are exported; Mutex<Option<Receiver<()>>> in a static is Sync). The Windows CI run is still the first real compile.

Verdict: changes requested. Blocking: W1.

## Re-review of #744 at `5897c7e9` (cold, fresh worktree) I read the core, `update_rt.rs`, `runtime.rs`, `fluxer-platform` (`lock.rs`, `velopack.rs`, `download.rs`, `http.rs`, `sweep.rs`), the tests and the spec at `5897c7e9`. I checked the answer in comment 7849 against the code rather than taking it on trust. I could not compile the `cfg(windows)` code; it was read by hand. The tokio and velopack behaviour cited below comes from their crate sources in the cargo registry (tokio 1.54, velopack 1.2.161). **Verdict: changes requested.** On Linux, B2 and B3 are fixed, and the core state machine is now clean. One blocking problem is left. It is Windows-only and in code that has never been compiled: a Velopack download that is not cancelled, or the new `IN_FLIGHT` wait, keeps the process alive after the window closes. That can also make Velopack give up on the install. ### Blocking **W1. Windows: a quit can leave a windowless process that does not exit, and the install on quit can fail with it.** Where: - `crates/fluxer-platform/src/update/velopack.rs:229-233` (the `IN_FLIGHT` wait); - `apps/fluxer/src/update_rt.rs:600-633` (`VelopackInstaller::download` runs on `spawn_blocking`); - `crates/fluxer-core/src/update.rs:581-601` (`on_quitting`); - `apps/fluxer/src/main.rs:77` and `:176` (main's tokio runtime is dropped at the end of `main`). Why the process stays alive: dropping a tokio `Runtime` waits **without limit** for every running `spawn_blocking` task (tokio 1.54 `runtime/blocking/pool.rs:343`, `BlockingPool::drop` → `shutdown(None)`). `VelopackInstaller::download` is such a task. Only its cancel token ends it early, and two paths never get there. 1. **The `IN_FLIGHT` wait ignores cancel.** `let _ = abandoned.recv();` blocks until the abandoned Velopack thread ends. Velopack's `HttpSource` is built without options, and ureq 3 then sets no timeout (velopack `download.rs:95-102`). A download that stalls (Wi-Fi change, sleep, dead TCP connection) can therefore block forever. - Scenario: channel switch while B downloads, so B is abandoned. The next download C (the new channel's check) blocks in `recv()`, and the UI shows "Downloading 0%" for as long as B lasts. - Scenario: B is abandoned by the skip click, then the next check starts C: same. - While blocked, nothing can end C. `CancelDownload` and `QuitDeadline` set a token that nobody reads until `recv()` returns. - On quit with something staged: after 30 s, `QuitDeadline` sends `Apply(A)`, and `apply_on_exit` starts `Update.exe`, which waits up to 60 s for the process to exit (`velopack.rs` doc). The process cannot exit while the blocking pool waits on `recv()`. After 60 s `Update.exe` gives up, so **nothing is installed** and a windowless process remains. 2. **Quit never cancels a download it does not wait for.** `on_quitting` returns at once when nothing is staged, or with `automatic` off and nothing asked for. It sends no `CancelDownload`, and dropping `UpdateRuntime` cancels nothing. The Velopack poll loop therefore runs until the whole download finishes, and the closed app stays in the process list until then. On a stall, that is forever. - Concrete case: the first update's download is running and the user closes the window. - This was already true before #740. It contradicts "with nothing staged, quitting fetches nothing", and #744 adds case 1 on top. Linux is not affected: AppImage downloads are async tasks, dropped with the runtime. Fixes, smallest first: - (a) In the `IN_FLIGHT` wait, use `recv_timeout(POLL)` in a loop that also checks `cancel` and returns `Cancelled`. - (b) Have `on_quitting` (or the runtime's `UpdateRuntime` drop) cancel any download it is not going to wait for. - (c) End `main` with `runtime.shutdown_timeout(…)` so blocking tasks can never hold the process. None of this has a test: there is no Windows build, and the `FakeInstaller` is async. ### Minor - **m1. `prepare` makes a blocking Velopack disk read on the async executor.** Where: `update_rt.rs:664-678`. `VelopackInstaller::prepare` calls `updater.pending()` (`get_update_pending_restart`: lists `packages` and reads the nupkg manifests) from `Executor::apply_update`. That breaks `VelopackUpdater`'s own rule ("Every call blocks … run it on a blocking task"). It is short, but it runs on a runtime worker. - **m2. The answer's "every install path installs the staged update" does not hold for a withdrawn release on Windows.** `keep` is a no-op for Velopack. When the withdrawn C finishes, `download_updates` has already deleted A's nupkg, so `prepare(A)` sees C and fails with "missing". Nothing wrong is installed, and the spec's §5.3 does say "otherwise the install fails". But the first install after a withdrawal fails once (Failed, Try again downloads A again). No test covers it. - **m3. The admitted residual race is real and fairly likely after `QuitDeadline`, though safe.** B is still downloading at 30 s and is abandoned. If it finishes during the ≤ ~10 s shutdown, `download_updates` deletes A's nupkg and also extracts B's `Squirrel.exe` over `Update.exe`. `apply_on_exit(A)` then returns `FileNotFound`, or `Update.exe` cannot find the package. Nothing is installed this time, and next run's `pending()` gives B instantly. Suggestions: log it; or, after `QuitDeadline` on Velopack, skip the install when an abandoned download is in flight rather than racing it. - **m4. A process started right after an update skips the start-up sweep.** - Linux: the old process still holds the `UpdateLock` while `appimage::relaunch` starts the new one. The lock lives in `UpdateRuntime` until `run()` ends, and the fd is `O_CLOEXEC`, so it is not inherited. The new process's start-up `take_lock` therefore fails ("another copy of the app is updating"), and `sweep_leftovers` is skipped for that run. - Updating is not disabled: the lock is retried lazily on the first download and install, by which time the old process has exited. - Harmless, but releasing the lock before relaunching (drop `update`'s lock before `installer.apply`) would make the log honest. - **m5. A second instance redownloads what the first installed.** P1 is in its ≤30 s quit wait, P2 starts and gets `Busy` and settles silently. P1 then swaps the AppImage under P2. P2 finds the same release at its next check (2 h), downloads it again and swaps the same version over itself on quit. This wastes bandwidth only. - **m6. A user's explicit request is silently dropped when another copy holds the lock.** `update.rs:988-993`. `Busy` on a user-started download (a click on `Available`) settles to Idle with no message, and the button disappears. Showing "another copy of Flaxative is updating" for user-started actions would be kinder. - **m7. Signals after the quit wait.** `insistence` installs tokio's SIGINT and SIGTERM handlers, and they stay for the life of the process. After the wait ends, the rest of the shutdown (gateway ≤5 s, writes ≤5 s, install) ignores SIGINT and SIGTERM. The same holds for SIGINT from the first Ctrl-C (`main.rs:292`) or a window close onward. The remaining shutdown is bounded on Linux, so this matters only together with W1. ### Your checks **(a) State machine.** I re-walked it with `Keep`, `withdrawn`, `look_again` and `Busy`. - No dead end: - every `Downloading` ends through `Downloaded` / `QuitDeadline` / the skip click / a channel switch; - `Applying` ends through `Apply` or `ApplyFailed`; - `Busy` settles to `Ready(staged)` or `Idle`. - No double apply: `apply_after_check` and `apply_after_download` are `take()`n; the quit loop stops on `exit_for_update` or when nothing is waited for. - Timers: the `look_again` re-check and the before-install check each schedule a new `next_check`. The id they replace is ignored when it fires, so there is never more than one live timer and none is lost. - No loop: `look_again` is set only by a newer manifest, and one failure without `look_again` returns to rest. `Busy` makes no immediate retry. - `Keep` is only sent from `on_downloaded`, after `staged` changed. It goes before `Apply`, and `Keep(None)` only when nothing is staged, so it never sweeps the update about to be installed. - `withdrawn` applies only to a manifest (or `UpToDate(Some)`) below the running download. A 404 and "no asset for this platform" do not count, which is right. **(b) The old blocking findings.** - **B1 (Windows replacement).** The core never replaces a running download, so the lock clash on replacement is gone. The cancel paths are left (channel switch, skip, `QuitDeadline`), and with them W1. - **B2 (wrong file installed).** I found no Linux scenario that still installs a file other than the one named: - `Apply{version}` resolves to `downloads[version]` and must be a file; - a cancel is checked after hashing (in `Downloader`) and again in the installer; - folders are removed only on `Keep`. On Windows the outcome is "fail, never install wrong" (m2, m3). - **B3 (quit wait).** - Quitting never checks the feed or downloads. - Nothing staged: no fetch and no wait in the runtime, but see W1 for Velopack. - The wait is bounded at 30 s; a second Ctrl-C or SIGTERM ends it (Unix; Windows `ctrl_c`). - Manifest requests have a 10 s total limit. - Two processes are guarded by `UpdateLock`. **(c) The lock.** - Stale lock after a crash: no. `flock` / `LockFileEx` locks are released when the process dies; only an empty dotfile remains. Its name, `.flaxative-update.lock`, does not match the sweep's `.flaxative-update-` prefix, so the sweep never removes it. - Taken before the start-up sweep: yes (`update_rt.rs:775`). - Relaunch: the new process does not get the lock at start (m4), but takes it lazily later, so updating is not disabled. - Read-only folder: `try_acquire` errors and `take_lock` lets it proceed, which is fine because such an install is `Manual` with no `lock_dir`. A missing folder is created. - NFS without `flock` falls into the same "proceed" path. **(d) Signals.** Nothing swallows Ctrl-C while the window is open or during the quit wait. After `supervise` breaks, and after the wait, SIGINT and SIGTERM are swallowed for the rest of a bounded shutdown (m7). The process can exit when the quit wait is not active on Linux. On Windows it cannot, while a Velopack download that was not cancelled is running (W1). **(e) Tests.** `FakeInstaller` is now honest: - it records only by version; - a cancelled download ends late and is never recorded; - `keep` drops the others; - `apply` installs the version named; - it has a lock folder. Every Linux blocking scenario has a test that asserts what was installed, including the real `AppImageInstaller` and `Downloader`: withdrawn, cancelled-late, exact version, quit at once, the quit wait and its deadline, insisting, two runtimes, a slow manifest. Not covered: the Windows paths (W1, m2, m3), and a test with no fake at all for a quit with nothing staged while a download runs. ### Gate `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` at `5897c7e9`: **all steps passed**, exit 0. Steps: ffmpeg, fmt, clippy, deny, core-isolation, parity, test, vendored-tests, screenshot-tests; livekit-interop skipped because `FLUXER_LIVEKIT_TESTS` is not 1. `textchat_session_end_to_end` passed on the first run. This is a Linux gate only. The `cfg(windows)` code (`velopack.rs` `imp`, `VelopackInstaller`) has not been compiled anywhere. I read it for type errors, cfg mistakes and unused imports and found none (`VelopackUpdater: Clone` and `PendingUpdate::version()` exist; `fluxer_platform::{Paths, APP_NAME}` are exported; `Mutex<Option<Receiver<()>>>` in a static is `Sync`). The Windows CI run is still the first real compile. **Verdict: changes requested.** Blocking: W1.
- W1 (a): the wait for an abandoned Velopack download polls the new
  download's cancel token (recv_timeout loop) and returns at once.
- W1 (b): quitting cancels every download it does not wait for; dropping
  the update runtime cancels what still runs; the runtime cancels after the
  quit wait.
- W1 (c): main ends its tokio runtime with shutdown_timeout (3 s) after the
  supervisor has waited for the writes and the install.
- m1: Velopack prepare reads the pending package off the async workers.
- m6: a click whose download gets Busy keeps its "Update available" button.
- m7: after the quit wait, Ctrl-C / SIGTERM end the process at once.
- m2/m3: spec §5.3 states both Windows outcomes; INFO logs for each.
- Dev server: UpdateFeed::stall_assets for a stalled download.

Refs #740

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Answer to the second review (commit f5707964; origin/textchat had not moved)

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: all steps passed (Linux). The cfg(windows) code is still uncompiled. I re-read every cfg(windows) line of this PR by hand for types, imports, unused items and borrows. Windows-only imports stay inside the cfg blocks. The one helper both OSes share, off_the_executor, is allow(dead_code) only off Windows and has a Linux unit test.

W1: a quit could leave a windowless process

All three fixes are in:

  • (a) The wait for an abandoned download is now cancellable. VelopackUpdater::download waits for the abandoned download with a recv_timeout(POLL) loop that checks the new download's cancel token. When it is cancelled, it puts the abandoned receiver back and returns Cancelled at once.
  • (b) Quitting stops every download it does not wait for. on_quitting sends CancelDownload for every such download: nothing staged, automatic off, or a manual download. It then settles. The runtime also cancels whatever still runs after the quit wait, and impl Drop for UpdateRuntime cancels too.
  • (c) The process end is bounded. main now ends with runtime::shut_down_runtime(runtime, RUNTIME_SHUTDOWN_LIMIT) (shutdown_timeout, 3 s). It runs after block_on(supervisor), and the supervisor already awaits the runtime task to its end. That task still waits for the gateway close, the settings and cache writes (as before, ≤ 5 s each) and the install. Only blocking tasks still running after that are left behind.

Tests:

  • Core: quitting_stops_a_download_it_does_not_wait_for (background with nothing staged, a click, a manual download, a newer download with automatic off; a download the quit waits for is not stopped).
  • Runtime: quitting_during_a_stalled_first_download_returns_at_once (real downloader, the dev server's new UpdateFeed::stall_assets(true), nothing staged; asserts the cancel and that it returns in under 5 s).
  • Process-level: the_process_end_never_waits_for_a_hung_blocking_task (a spawn_blocking task that never ends; shut_down_runtime returns in under 2 s).
  • Not tested: the Velopack wait itself, which needs Windows.

Minor findings

  • m1: VelopackInstaller::prepare runs updater.pending() through off_the_executor (block_in_place on a multi-threaded runtime, otherwise directly). I kept the check in prepare rather than moving it to the install after shutdown. A failure there still reaches the user as an error, instead of the app closing without relaunching. Test: blocking_work_runs_off_the_executor_on_any_runtime.

  • m2, m3: no behaviour change. Spec §5.3 now states both exactly:

    • after a withdrawal on Windows, the first install can fail once, and "Try again" downloads the staged version again;
    • if a newer download finishes during the shutdown after the quit deadline, nothing is installed this run, and the next start finds the newer one.

    Each case has an INFO log line: in VelopackInstaller::prepare when Velopack holds another version, and in apply when an abandoned download is still running (velopack::abandoned_download_running()).

  • m4, m5: no change, as agreed.

  • m6: my choice is to keep the button. A click whose download gets Busy returns to Available, so the button stays "Update available" and can be clicked again. No error is shown and there is an INFO log line. A background download that gets Busy still settles quietly. Test: another_copy_updating_is_silent.

  • m7: after the quit wait, exit_on_signal makes Ctrl-C or SIGTERM end the process at once (exit code 130, with a warning in the log). The second-Ctrl-C handling is now shared code. Not tested: it would mean signalling the test process.

Untested on Windows

The whole cfg(windows) path is untested: the IN_FLIGHT cancel loop, abandoned_download_running, off_the_executor around pending(), and both INFO logs. The Windows CI run is the first compile.

🤖 Generated with Claude Code

## Answer to the second review (commit f5707964; `origin/textchat` had not moved) `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: all steps passed (Linux). The `cfg(windows)` code is still uncompiled. I re-read every `cfg(windows)` line of this PR by hand for types, imports, unused items and borrows. Windows-only imports stay inside the cfg blocks. The one helper both OSes share, `off_the_executor`, is `allow(dead_code)` only off Windows and has a Linux unit test. ### W1: a quit could leave a windowless process All three fixes are in: - **(a) The wait for an abandoned download is now cancellable.** `VelopackUpdater::download` waits for the abandoned download with a `recv_timeout(POLL)` loop that checks the new download's cancel token. When it is cancelled, it puts the abandoned receiver back and returns `Cancelled` at once. - **(b) Quitting stops every download it does not wait for.** `on_quitting` sends `CancelDownload` for every such download: nothing staged, `automatic` off, or a manual download. It then settles. The runtime also cancels whatever still runs after the quit wait, and `impl Drop for UpdateRuntime` cancels too. - **(c) The process end is bounded.** `main` now ends with `runtime::shut_down_runtime(runtime, RUNTIME_SHUTDOWN_LIMIT)` (`shutdown_timeout`, 3 s). It runs after `block_on(supervisor)`, and the supervisor already awaits the runtime task to its end. That task still waits for the gateway close, the settings and cache writes (as before, ≤ 5 s each) and the install. Only blocking tasks still running after that are left behind. Tests: - Core: `quitting_stops_a_download_it_does_not_wait_for` (background with nothing staged, a click, a manual download, a newer download with `automatic` off; a download the quit waits for is not stopped). - Runtime: `quitting_during_a_stalled_first_download_returns_at_once` (real downloader, the dev server's new `UpdateFeed::stall_assets(true)`, nothing staged; asserts the cancel and that it returns in under 5 s). - Process-level: `the_process_end_never_waits_for_a_hung_blocking_task` (a `spawn_blocking` task that never ends; `shut_down_runtime` returns in under 2 s). - Not tested: the Velopack wait itself, which needs Windows. ### Minor findings - **m1:** `VelopackInstaller::prepare` runs `updater.pending()` through `off_the_executor` (`block_in_place` on a multi-threaded runtime, otherwise directly). I kept the check in `prepare` rather than moving it to the install after shutdown. A failure there still reaches the user as an error, instead of the app closing without relaunching. Test: `blocking_work_runs_off_the_executor_on_any_runtime`. - **m2, m3:** no behaviour change. Spec §5.3 now states both exactly: - after a withdrawal on Windows, the first install can fail once, and "Try again" downloads the staged version again; - if a newer download finishes during the shutdown after the quit deadline, nothing is installed this run, and the next start finds the newer one. Each case has an INFO log line: in `VelopackInstaller::prepare` when Velopack holds another version, and in `apply` when an abandoned download is still running (`velopack::abandoned_download_running()`). - **m4, m5:** no change, as agreed. - **m6:** my choice is to keep the button. A click whose download gets `Busy` returns to `Available`, so the button stays "Update available" and can be clicked again. No error is shown and there is an INFO log line. A background download that gets `Busy` still settles quietly. Test: `another_copy_updating_is_silent`. - **m7:** after the quit wait, `exit_on_signal` makes Ctrl-C or SIGTERM end the process at once (exit code 130, with a warning in the log). The second-Ctrl-C handling is now shared code. Not tested: it would mean signalling the test process. ### Untested on Windows The whole `cfg(windows)` path is untested: the `IN_FLIGHT` cancel loop, `abandoned_download_running`, `off_the_executor` around `pending()`, and both INFO logs. The Windows CI run is the first compile. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Third review of #744: only the 5897c7e9..f5707964 delta

I read the delta cold and checked each claim of comment 7882 against the code. I also read every changed cfg(windows) line the way the compiler and clippy -D warnings would.

Verdict: approve. W1 is fixed. Nothing I approved before has regressed. Three minor points remain, none of them blocking.

Claims checked

  • W1 (a), the IN_FLIGHT wait (velopack.rs:241-255). It is now a recv_timeout(POLL) loop. On cancel it puts the receiver back and returns Cancelled; a disconnected receiver ends the wait. It compiles as written: moving abandoned into the static and then returning from inside the loop is accepted by the borrow checker.
  • W1 (b), quit cancels the downloads it does not wait for.
    • on_quitting (update.rs:583-600) sends CancelDownload for every download it does not wait for: nothing staged, automatic off and nothing asked, or a manual download. It then settles. A download that quit does wait for is untouched.
    • The runtime calls cancel_download() after the quit wait (runtime.rs:924).
    • Drop for UpdateRuntime cancels too.
    • The Linux paths and the state machine are unchanged, apart from this early cancel.
  • W1 (c), bounded runtime shutdown (main.rs:176-180, runtime.rs:1016-1023).
    • block_on(supervisor) only returns once Handle::shutdown has awaited the runtime task.
    • That task has already:
      • closed the gateway;
      • waited up to 5 s for the persist worker;
      • run installer.apply on spawn_blocking and awaited it. On Windows, that is where apply_on_exit starts Update.exe.
    • So the 3 s shutdown_timeout only cuts blocking tasks that are still running after that. It cannot cut the install. shutdown_timeout is called on the main thread, outside any async context, so it does not panic.
  • m1, off_the_executor. block_in_place runs only for a MultiThread flavour; any other flavour calls the work directly, so a current-thread runtime cannot panic. The only caller is Executor::apply_update, which runs on a worker of the multi-thread runtime. It is never inside spawn_blocking or a LocalSet.
  • m6. A user-started download that gets Busy with nothing staged goes back to Available. With something staged it settles to Ready. In the background it stays quiet. A test covers each case.
  • m7, exit_on_signal. Ctrl-C or SIGTERM after the quit wait calls process::exit(130). This exit cannot leave a half-written file:
    • settings are written to a temporary file and renamed;
    • the cache is SQLite inside a transaction;
    • the AppImage swap is a single rename;
    • for Velopack, apply_on_exit only starts Update.exe.
      At worst the write or the relaunch is lost, which is what the user asked for.
  • Windows lines read as a compiler would. No problems found:
    • the re-export of abandoned_download_running and its call are both cfg(windows);
    • try_recv on the guard's &Receiver is fine;
    • in prepare, the temporary guard in the match scrutinee is dropped before the store, and updater is moved only after the FnOnce closure;
    • off_the_executor carries allow(dead_code) off Windows and is used by a unit test;
    • nothing default-clippy rejects.

Minor (not blocking)

  1. Putting the receiver back can race a second waiter. velopack.rs:247-249. Scenario: download C is waiting on the abandoned B and is cancelled because a new download D starts. D's in_flight().take() can run in the up-to-100 ms before C puts B's receiver back.
    • D then sees nothing to wait for and calls download_updates while B still holds Velopack's lock, so D fails at once with a lock error. The user sees Failed if they started it; otherwise it is retried at the next check.
    • If D is then cancelled too, C's store can overwrite D's receiver, which loses track of one abandoned download.
    • No wrong install and no hang. A fix: hold a Condvar or keep one global "abandoned" list instead of a single take-and-put-back slot.
  2. Shutdown now has a hard limit, so a slow storage write can be lost. Before, dropping the runtime waited without limit for the persist worker; now it gets 5 s plus 3 s, then the process ends. The writes are atomic, so data is lost, not corrupted. Documenting this would be enough.
  3. Exit code. exit_on_signal exits with 130 for SIGTERM too (143 would be the convention). Cosmetic.

Not verified

  • The Windows code has still never been compiled or run. The Windows CI run is the first build.
  • The real-world Velopack race (m3 of my previous comment) is only logged now, not tested.

Evidence

  • cargo test -p fluxer-core --test update: 53 passed.
  • cargo test -p fluxer --test update_runtime: 27 passed.
  • cargo test -p fluxer --lib update_rt: 6 passed, including blocking_work_runs_off_the_executor_on_any_runtime.
  • I did not re-run the full gate; nothing in the delta gave me reason to doubt it.

Verdict: approve.

## Third review of #744: only the `5897c7e9..f5707964` delta I read the delta cold and checked each claim of comment 7882 against the code. I also read every changed `cfg(windows)` line the way the compiler and `clippy -D warnings` would. **Verdict: approve.** W1 is fixed. Nothing I approved before has regressed. Three minor points remain, none of them blocking. ### Claims checked - **W1 (a), the `IN_FLIGHT` wait** (`velopack.rs:241-255`). It is now a `recv_timeout(POLL)` loop. On cancel it puts the receiver back and returns `Cancelled`; a disconnected receiver ends the wait. It compiles as written: moving `abandoned` into the static and then returning from inside the loop is accepted by the borrow checker. - **W1 (b), quit cancels the downloads it does not wait for.** - `on_quitting` (`update.rs:583-600`) sends `CancelDownload` for every download it does not wait for: nothing staged, `automatic` off and nothing asked, or a manual download. It then settles. A download that quit does wait for is untouched. - The runtime calls `cancel_download()` after the quit wait (`runtime.rs:924`). - `Drop for UpdateRuntime` cancels too. - The Linux paths and the state machine are unchanged, apart from this early cancel. - **W1 (c), bounded runtime shutdown** (`main.rs:176-180`, `runtime.rs:1016-1023`). - `block_on(supervisor)` only returns once `Handle::shutdown` has awaited the runtime task. - That task has already: - closed the gateway; - waited up to 5 s for the persist worker; - run `installer.apply` on `spawn_blocking` and awaited it. On Windows, that is where `apply_on_exit` starts `Update.exe`. - So the 3 s `shutdown_timeout` only cuts blocking tasks that are still running after that. It cannot cut the install. `shutdown_timeout` is called on the main thread, outside any async context, so it does not panic. - **m1, `off_the_executor`.** `block_in_place` runs only for a `MultiThread` flavour; any other flavour calls the work directly, so a current-thread runtime cannot panic. The only caller is `Executor::apply_update`, which runs on a worker of the multi-thread runtime. It is never inside `spawn_blocking` or a `LocalSet`. - **m6.** A user-started download that gets `Busy` with nothing staged goes back to `Available`. With something staged it settles to `Ready`. In the background it stays quiet. A test covers each case. - **m7, `exit_on_signal`.** Ctrl-C or SIGTERM after the quit wait calls `process::exit(130)`. This exit cannot leave a half-written file: - settings are written to a temporary file and renamed; - the cache is SQLite inside a transaction; - the AppImage swap is a single rename; - for Velopack, `apply_on_exit` only starts `Update.exe`. At worst the write or the relaunch is lost, which is what the user asked for. - **Windows lines read as a compiler would.** No problems found: - the re-export of `abandoned_download_running` and its call are both `cfg(windows)`; - `try_recv` on the guard's `&Receiver` is fine; - in `prepare`, the temporary guard in the `match` scrutinee is dropped before the store, and `updater` is moved only after the `FnOnce` closure; - `off_the_executor` carries `allow(dead_code)` off Windows and is used by a unit test; - nothing default-clippy rejects. ### Minor (not blocking) 1. **Putting the receiver back can race a second waiter.** `velopack.rs:247-249`. Scenario: download C is waiting on the abandoned B and is cancelled because a new download D starts. D's `in_flight().take()` can run in the up-to-100 ms before C puts B's receiver back. - D then sees nothing to wait for and calls `download_updates` while B still holds Velopack's lock, so D fails at once with a lock error. The user sees `Failed` if they started it; otherwise it is retried at the next check. - If D is then cancelled too, C's store can overwrite D's receiver, which loses track of one abandoned download. - No wrong install and no hang. A fix: hold a `Condvar` or keep one global "abandoned" list instead of a single take-and-put-back slot. 2. **Shutdown now has a hard limit, so a slow storage write can be lost.** Before, dropping the runtime waited without limit for the persist worker; now it gets 5 s plus 3 s, then the process ends. The writes are atomic, so data is lost, not corrupted. Documenting this would be enough. 3. **Exit code.** `exit_on_signal` exits with 130 for SIGTERM too (143 would be the convention). Cosmetic. ### Not verified - The Windows code has still never been compiled or run. The Windows CI run is the first build. - The real-world Velopack race (m3 of my previous comment) is only logged now, not tested. ### Evidence - `cargo test -p fluxer-core --test update`: 53 passed. - `cargo test -p fluxer --test update_runtime`: 27 passed. - `cargo test -p fluxer --lib update_rt`: 6 passed, including `blocking_work_runs_off_the_executor_on_any_runtime`. - I did not re-run the full gate; nothing in the delta gave me reason to doubt it. **Verdict: approve.**
Author
Owner

Approved on the third review; merged into textchat by hand (the merge API returns 405); the commits are in the branch.

Approved on the third review; merged into `textchat` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-16 06:38:47 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.