From c64c028366cdcd80af373842f4b10290bddac495 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 20 Jul 2024 11:43:09 +0200 Subject: fix(tvix/store): add missing nar_info::ca::Hash::TextSha256 Also reorder to how it's ordered in the .proto file. Change-Id: I87c422feac4d12f6a84f99aa889f9c524a9878b9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11985 Tested-by: BuildkiteCI Reviewed-by: Brian Olsen --- tvix/store/src/proto/mod.rs | 47 +++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'tvix/store') diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs index a09839c8bdf9..b45e6fda46fe 100644 --- a/tvix/store/src/proto/mod.rs +++ b/tvix/store/src/proto/mod.rs @@ -260,24 +260,19 @@ impl TryFrom<&nar_info::Ca> for nix_compat::nixhash::CAHash { fn try_from(value: &nar_info::Ca) -> Result { Ok(match value.r#type { - typ if typ == nar_info::ca::Hash::FlatMd5 as i32 => { - Self::Flat(NixHash::Md5(value.digest[..].try_into().map_err(|_| { - ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatMd5") - })?)) - } - typ if typ == nar_info::ca::Hash::FlatSha1 as i32 => { - Self::Flat(NixHash::Sha1(value.digest[..].try_into().map_err( - |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha1"), + typ if typ == nar_info::ca::Hash::NarSha256 as i32 => { + Self::Nar(NixHash::Sha256(value.digest[..].try_into().map_err( + |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha256"), )?)) } - typ if typ == nar_info::ca::Hash::FlatSha256 as i32 => { - Self::Flat(NixHash::Sha256(value.digest[..].try_into().map_err( - |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha256"), + typ if typ == nar_info::ca::Hash::NarSha1 as i32 => { + Self::Nar(NixHash::Sha1(value.digest[..].try_into().map_err( + |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha1"), )?)) } - typ if typ == nar_info::ca::Hash::FlatSha512 as i32 => Self::Flat(NixHash::Sha512( + typ if typ == nar_info::ca::Hash::NarSha512 as i32 => Self::Nar(NixHash::Sha512( Box::new(value.digest[..].try_into().map_err(|_| { - ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha512") + ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha512") })?), )), typ if typ == nar_info::ca::Hash::NarMd5 as i32 => { @@ -285,19 +280,29 @@ impl TryFrom<&nar_info::Ca> for nix_compat::nixhash::CAHash { ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarMd5") })?)) } - typ if typ == nar_info::ca::Hash::NarSha1 as i32 => { - Self::Nar(NixHash::Sha1(value.digest[..].try_into().map_err( - |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha1"), + typ if typ == nar_info::ca::Hash::TextSha256 as i32 => { + Self::Text(value.digest[..].try_into().map_err(|_| { + ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "TextSha256") + })?) + } + typ if typ == nar_info::ca::Hash::FlatSha1 as i32 => { + Self::Flat(NixHash::Sha1(value.digest[..].try_into().map_err( + |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha1"), )?)) } - typ if typ == nar_info::ca::Hash::NarSha256 as i32 => { - Self::Nar(NixHash::Sha256(value.digest[..].try_into().map_err( - |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha256"), + typ if typ == nar_info::ca::Hash::FlatMd5 as i32 => { + Self::Flat(NixHash::Md5(value.digest[..].try_into().map_err(|_| { + ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatMd5") + })?)) + } + typ if typ == nar_info::ca::Hash::FlatSha256 as i32 => { + Self::Flat(NixHash::Sha256(value.digest[..].try_into().map_err( + |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha256"), )?)) } - typ if typ == nar_info::ca::Hash::NarSha512 as i32 => Self::Nar(NixHash::Sha512( + typ if typ == nar_info::ca::Hash::FlatSha512 as i32 => Self::Flat(NixHash::Sha512( Box::new(value.digest[..].try_into().map_err(|_| { - ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha512") + ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha512") })?), )), typ => return Err(ConvertCAError::UnknownHashType(typ)), -- cgit 1.4.1