refactor(tvix/store/pathinfo/nix_http): NixHash to display NARHash

This will give us the sha256: prefix, and hashes we're more used to, in
that context.

Change-Id: I72e42fe685e365ba9baa7cd81001387d239fa7c8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11194
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2024-03-18 15:28:10 +02:00 committed by flokli
parent d62c6e642d
commit a65c49fbc3

View file

@ -5,6 +5,7 @@ use futures::{stream::BoxStream, TryStreamExt};
use nix_compat::{
narinfo::{self, NarInfo},
nixbase32,
nixhash::NixHash,
};
use reqwest::StatusCode;
use sha2::{digest::FixedOutput, Digest, Sha256};
@ -223,10 +224,11 @@ where
io::ErrorKind::InvalidData,
"NarSize mismatch".to_string(),
))?;
} else if narinfo.nar_hash != nar_hash {
}
if narinfo.nar_hash != nar_hash {
warn!(
narinfo.nar_hash = BASE64.encode(&narinfo.nar_hash),
http.nar_hash = BASE64.encode(&nar_hash),
narinfo.nar_hash = %NixHash::Sha256(narinfo.nar_hash),
http.nar_hash = %NixHash::Sha256(nar_hash),
"NarHash mismatch"
);
Err(io::Error::new(