Skip to main content

check_cache

Function check_cache 

Source
pub fn check_cache(cache_dir: &Utf8Path, version: &str) -> CacheLookupResult
Expand description

Checks if the cache contains valid binaries for the given version.

A cache entry is considered valid if:

  1. The version directory exists
  2. The .complete marker file is present
  3. The bin subdirectory exists (indicating extracted binaries)

§Arguments

  • cache_dir - Root directory of the binary cache
  • version - Exact version string to look up (e.g., “17.4.0”)

§Examples

use camino::Utf8Path;
use pg_embedded_setup_unpriv::cache::{check_cache, CacheLookupResult};

let cache_dir = Utf8Path::new("/home/user/.cache/pg-embedded/binaries");
match check_cache(cache_dir, "17.4.0") {
    CacheLookupResult::Hit { source_dir } => {
        println!("Found cached binaries at {source_dir}");
    }
    CacheLookupResult::Miss => {
        println!("Cache miss, need to download");
    }
}