fix(nix-compat/nixhash): fix from_nix_nixbase32_str fn name

This was decoding nixbase32, not hex. Its only consumer (in ca_hash.rs)
was right in its docstring about how it behaves, only was calling the
wrongly-named function.

Change-Id: I97ea273706ba818d16a61b1574989db800f78ead
Reviewed-on: https://cl.snix.dev/c/snix/+/30553
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
This commit is contained in:
Florian Klink 2025-06-03 22:34:55 +03:00 committed by clbot
parent 80b5206034
commit 2a01c40e77
2 changed files with 6 additions and 6 deletions

View file

@ -85,9 +85,9 @@ impl CAHash {
} }
"fixed" => { "fixed" => {
if let Some(s) = s.strip_prefix("r:") { if let Some(s) = s.strip_prefix("r:") {
NixHash::from_nix_hex_str(s).map(CAHash::Nar) NixHash::from_nix_nixbase32_str(s).map(CAHash::Nar)
} else { } else {
NixHash::from_nix_hex_str(s).map(CAHash::Flat) NixHash::from_nix_nixbase32_str(s).map(CAHash::Flat)
} }
} }
_ => None, _ => None,

View file

@ -73,9 +73,9 @@ impl NixHash {
} }
} }
/// Constructs a [NixHash] from the Nix default hash format, /// Constructs a new [NixHash] from the Nix default hash format,
/// the inverse of [Self::to_nix_hex_string]. /// the inverse of [Self::to_nix_nixbase32_string].
pub fn from_nix_hex_str(s: &str) -> Option<Self> { pub fn from_nix_nixbase32_str(s: &str) -> Option<Self> {
let (tag, digest) = s.split_once(':')?; let (tag, digest) = s.split_once(':')?;
(match tag { (match tag {
@ -98,7 +98,7 @@ impl NixHash {
/// Formats a [NixHash] in the format that's used inside CAHash, /// Formats a [NixHash] in the format that's used inside CAHash,
/// which is the algo, followed by a colon, then the nixbase32-encoded digest. /// which is the algo, followed by a colon, then the nixbase32-encoded digest.
pub(crate) fn to_nix_nixbase32_string(&self) -> String { pub fn to_nix_nixbase32_string(&self) -> String {
format!( format!(
"{}:{}", "{}:{}",
self.algo(), self.algo(),