Skip to main content

Module update

Module update 

Source
Expand description

Auto-update: poll a GitHub Releases feed, download cargo-dist’s platform installer when a newer semver is available, and re-exec ourselves so the new binary takes over.

The update task in runtime.rs only invokes us when the worker is idle (no job in flight) so generation runs never get killed mid-flow.

All side-effecting bits (HTTP, filesystem writes, process spawn) flow through testable helpers; see apply_with for the seam.

Structs§

RealRunner

Enums§

CheckOutcome

Traits§

UpdateRunner
Side-effect abstraction for apply_with. The real implementation downloads via HTTP and runs sh / powershell; tests inject a fake that records calls.

Functions§

apply
Apply an update by downloading the cargo-dist installer for the current platform and running it.
apply_with
check
Compare the local version against the feed and decide whether to update.
decide
Pure decision function so we can unit-test the prerelease/draft filters without going through HTTP.
fetch_releases
Resolve the feed URL to a JSON document and parse a release list.
installer_asset_name
The cargo-dist installer asset name for the current platform.
parse_releases
Pure parser separated from the HTTP call so it’s trivially testable.
parse_tag
Parse the version from a release tag. Accepts both 1.2.3 and v1.2.3.
resolve_installer_url
Resolve which installer asset to download for the given release. Pulled out of apply for unit tests.
restart_argv
Compute the (binary, args) tuple we’d re-exec ourselves with. Pure — actual exec lives in restart_self.
restart_self
Replace the current process with a fresh exec of the (now-updated) binary. On unix we use execvp; on Windows we spawn the successor and exit cleanly. Unreachable from tests — covered by integration tests of apply_with instead.