Skip to main content

verify_cache

Function verify_cache 

Source
pub async fn verify_cache(
    repo_id: &str,
    token: Option<&str>,
    revision: Option<&str>,
) -> Result<Vec<FileVerification>, FetchError>
Expand description

Verifies SHA256 digests of cached files against HuggingFace LFS metadata.

Fetches the expected hashes from the HuggingFace API and, for each file that has an LFS SHA256, reads the local cached file and compares.

Files without LFS metadata (small git-stored files such as config.json) are reported as VerifyStatus::Skipped; files absent from the snapshot directory are reported as VerifyStatus::Missing. Both are non-failures — only VerifyStatus::Mismatch indicates a corrupted file.

revision defaults to "main" when None. Requires network access for the metadata fetch; the per-file digest computation is local-only.

For long verifications (multi-GiB safetensors files), prefer verify_cache_with_progress so a CLI / GUI can render a spinner or progress bar while each file is hashed.

§Errors

Returns FetchError::Http if the HuggingFace API request fails. Returns FetchError::Io when a local cached file is present but cannot be read.