hex/src/updater
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Dax 9ea343f69d
fix(updater): keep one .Hex-update folder, not one per staged dev build (#1867)
* fix(updater): keep one .Hex-update folder, not one per staged dev build

Every staged release unpacked its own `.Hex-update-<version>` folder beside
`Hex.app`, and the only removal was `finish_on_launch`. The Dev channel checks
every ten minutes, so a Hex that runs for days staged a full ~80 MB copy of the
app per published build and left every one of them in `/Applications`
(the folder it replaces was never removed); the launch sweep only ran when Hex
next started, which for a menu-bar app can be days.

Staging a newer release now removes the folder of the one it replaces, once
the replacement is the staged update, so a running install holds exactly one
folder and the app can never be caught without its staged update. The launch
sweep stays as the safety net for a swap or an interrupted stage, and now
skips symlinks (never followed) and the running bundle itself.

The sweep moved to `updater/staging.rs` so it can be tested off macOS:
`launch_cleanup_removes_every_unpacked_update_but_the_running_bundle`,
`a_newer_update_removes_the_folder_of_the_one_it_replaces`,
`a_bundle_running_from_a_staging_folder_keeps_that_folder`, and
`a_symlink_named_like_a_staged_update_is_never_followed`, plus the macOS-only
`a_newer_staged_release_removes_the_folder_of_the_one_it_replaces`.

Observed on macOS 26 with the published 0.0.0-dev-1046 build: the launch sweep
removed both a folder holding an older signed build and one holding a
swapped-in peer beside /Applications/Hex.app.

* fix(updater): never stage a release after a quit installed one

a quit installs the staged update itself (`install_on_quit`) while the updater
thread can still be in `check()`. two things went wrong in that window:

- the late `check` overwrote `shared.staged`, and its `remove_superseded` then
  deleted the folder holding the bundle the quit had just replaced (the one
  the draining process runs from), orphaning the release it had unpacked.
- `finish_restart` swapped again after `install_on_quit` had applied the
  update, exchanging the same two bundles back and losing the update.

`check` now takes the state and staged locks together, in the order
`install_on_quit` takes them, and refuses a release that lands while quitting or
after `State::Applied`: it removes the folder it unpacked and keeps the
installed update. `finish_restart` reports done without swapping once the state
is Applied. The macOS `discard` helper removes that unused folder.

`staging::remove_beside` now canonicalizes the bundle's folder and compares the
kept folder by name (only when its own folder resolves there), so a `..`, `./`,
or symlinked spelling still names the folder to keep, and a path outside it
protects nothing.

tests: `a_restart_after_a_quit_installed_the_update_does_not_swap_again` (fails
without the Applied guard), `a_release_that_finishes_staging_after_a_quit_installed_one_is_discarded`
(fails when the decision adopts everything), and
`the_folder_to_keep_is_recognized_through_a_non_canonical_spelling` (fails with
the old raw path comparison).
2026-11-15 18:20:36 -05:00
..
legacy.rs Windows: hex.com console entry point beside the GUI hex.exe (#1374) 2026-11-05 06:52:51 -05:00
linux.rs Windows: a receipted install always updates itself, and one that can't says why (#1352) (#1353) 2026-11-04 23:42:39 -05:00
macos.rs fix(updater): keep one .Hex-update folder, not one per staged dev build (#1867) 2026-11-15 18:20:36 -05:00
notes.rs ci: read release secrets from aws secrets manager (#1606) 2026-11-09 15:18:26 -05:00
protocol.rs Security: sign Linux releases, lock the installers, vendor the release client, pin actions and download hosts (#370) 2026-10-29 11:06:30 -04:00
staging.rs fix(updater): keep one .Hex-update folder, not one per staged dev build (#1867) 2026-11-15 18:20:36 -05:00
transport.rs Model downloads, updates and fetch work behind proxies and TLS inspection (#894) (#909) 2026-11-01 15:56:03 -05:00
windows.rs Windows: hex.com console entry point beside the GUI hex.exe (#1374) 2026-11-05 06:52:51 -05:00