Skip to main content

Module ui_bundle_resolver

Module ui_bundle_resolver 

Source
Expand description

red ui bundle resolver — pin→URL resolution, HTTPS download, SHA-256 verification, tgz extraction, and local cache management.

Implements the runtime download path described in ADR 0050:

  1. The pinned red-ui version and its bundle SHA-256 are build-time constants set by CI (RED_UI_PINNED_VERSION / RED_UI_PINNED_SHA256).
  2. resolve_ui_bundle checks ~/.cache/reddb/ui/<version>/ for a cached bundle whose manifest matches the pin. Cache hit → returns the directory immediately (no network call).
  3. On a cache miss it downloads the GitHub release asset, verifies the SHA-256 (refuses on mismatch), extracts the tgz into a staging directory, writes a manifest, and atomically promotes the staging directory to the live version directory.
  4. Offline first-run with no cached bundle fails with a clear, actionable io::Error message.

The UiBundleFetcher trait makes the network layer injectable for tests.

Structs§

HttpFetcher
Production fetcher — HTTPS via ureq with rustls, per ADR 0050.

Constants§

RED_UI_PINNED_SHA256
SHA-256 (lower-case hex) of the ui-dist.tgz for the pinned version. CI sets this alongside RED_UI_PINNED_VERSION.
RED_UI_PINNED_VERSION
Exact red-ui version this red binary was tested against. CI that validates the redred-ui pair sets this before the release build.

Traits§

UiBundleFetcher
Abstraction over the network layer so tests can inject a fake without making real HTTP calls.

Functions§

reddb_user_cache_root
Compute ~/.cache/reddb (XDG-aware on Linux, standard on macOS/Windows).
release_asset_url
GitHub release asset URL for a given red-ui version.
resolve_ui_bundle
Ensure the pinned red-ui bundle is cached and return its directory.