diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs index a09839c8b..b45e6fda4 100644 --- a/tvix/store/src/proto/mod.rs +++ b/tvix/store/src/proto/mod.rs @@ -260,16 +260,41 @@ 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::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::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::NarSha512 as i32 => Self::Nar(NixHash::Sha512( + Box::new(value.digest[..].try_into().map_err(|_| { + ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha512") + })?), + )), + typ if typ == nar_info::ca::Hash::NarMd5 as i32 => { + Self::Nar(NixHash::Md5(value.digest[..].try_into().map_err(|_| { + ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarMd5") })?)) } + 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::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"), @@ -280,26 +305,6 @@ impl TryFrom<&nar_info::Ca> for nix_compat::nixhash::CAHash { ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha512") })?), )), - typ if typ == nar_info::ca::Hash::NarMd5 as i32 => { - Self::Nar(NixHash::Md5(value.digest[..].try_into().map_err(|_| { - 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::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::NarSha512 as i32 => Self::Nar(NixHash::Sha512( - Box::new(value.digest[..].try_into().map_err(|_| { - ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha512") - })?), - )), typ => return Err(ConvertCAError::UnknownHashType(typ)), }) }