Skip to main content

resolve_ui_bundle

Function resolve_ui_bundle 

Source
pub fn resolve_ui_bundle(
    reddb_cache_root: &Path,
    fetcher: &dyn UiBundleFetcher,
) -> Result<PathBuf, Error>
Expand description

Ensure the pinned red-ui bundle is cached and return its directory.

§Behaviour

  1. Cache hit: if <reddb_cache_root>/ui/<version>/manifest.json exists and records the pinned version and SHA-256, return the directory immediately — no network call.
  2. Cache miss: download the release asset via fetcher, verify SHA-256 (reject on mismatch), extract the tgz into a staging directory, write the manifest, and atomically promote to the live version directory.
  3. Offline first-run: if fetcher returns an error and no cached bundle exists, propagate a clear io::Error with an actionable message.

reddb_cache_root is the ~/.cache/reddb base (use reddb_user_cache_root to derive it). In tests, pass a TempDir path to keep caches isolated.