MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / verify_descriptor_digest

Function verify_descriptor_digest

crates/openshell-driver-vm/src/driver.rs:3758–3771  ·  view source on GitHub ↗
(path: &Path, expected_digest: &str)

Source from the content-addressed store, hash-verified

3756}
3757
3758fn verify_descriptor_digest(path: &Path, expected_digest: &str) -> Result<(), String> {
3759 let expected = expected_digest
3760 .strip_prefix("sha256:")
3761 .ok_or_else(|| format!("unsupported layer digest '{expected_digest}'"))?;
3762 let actual = compute_file_sha256_hex(path)?;
3763 if actual == expected {
3764 Ok(())
3765 } else {
3766 Err(format!(
3767 "digest mismatch for {}: expected sha256:{expected}, got sha256:{actual}",
3768 path.display()
3769 ))
3770 }
3771}
3772
3773fn compute_file_sha256_hex(path: &Path) -> Result<String, String> {
3774 let mut file = fs::File::open(path).map_err(|err| format!("open {}: {err}", path.display()))?;

Calls 1

compute_file_sha256_hexFunction · 0.85

Tested by

no test coverage detected