refactor(nix-compat/store_path/utils): move helper function in
This is only used inside this function, in 2 of the match cases. Change-Id: Ib361f5ee0e3b203802f7d05b9a7f332d14bbcf80 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11143 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: John Ericson <git@johnericson.me> Tested-by: BuildkiteCI
This commit is contained in:
parent
43c851bc84
commit
98e6936301
1 changed files with 7 additions and 8 deletions
|
@ -66,6 +66,13 @@ pub fn build_ca_path<'a, S: AsRef<str>, I: IntoIterator<Item = S>>(
|
||||||
return Err(BuildStorePathError::InvalidReference());
|
return Err(BuildStorePathError::InvalidReference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper function, used for the non-sha256 [CAHash::Nar] and all [CAHash::Flat].
|
||||||
|
fn fixed_out_digest(prefix: &str, hash: &NixHash) -> [u8; 32] {
|
||||||
|
Sha256::new_with_prefix(format!("{}:{}:", prefix, hash.to_nix_hex_string()))
|
||||||
|
.finalize()
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
let (ty, inner_digest) = match &ca_hash {
|
let (ty, inner_digest) = match &ca_hash {
|
||||||
CAHash::Text(ref digest) => (make_references_string("text", references, false), *digest),
|
CAHash::Text(ref digest) => (make_references_string("text", references, false), *digest),
|
||||||
CAHash::Nar(NixHash::Sha256(ref digest)) => (
|
CAHash::Nar(NixHash::Sha256(ref digest)) => (
|
||||||
|
@ -101,14 +108,6 @@ pub fn build_ca_path<'a, S: AsRef<str>, I: IntoIterator<Item = S>>(
|
||||||
.map_err(BuildStorePathError::InvalidStorePath)
|
.map_err(BuildStorePathError::InvalidStorePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function, used in [build_ca_path] for the non-sha256 [CAHash::Nar]
|
|
||||||
/// and [CAHash::Flat].
|
|
||||||
fn fixed_out_digest(prefix: &str, hash: &NixHash) -> [u8; 32] {
|
|
||||||
Sha256::new_with_prefix(format!("{}:{}:", prefix, hash.to_nix_hex_string()))
|
|
||||||
.finalize()
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// For given NAR sha256 digest and name, return the new [StorePathRef] this
|
/// For given NAR sha256 digest and name, return the new [StorePathRef] this
|
||||||
/// would have, or an error, in case the name is invalid.
|
/// would have, or an error, in case the name is invalid.
|
||||||
pub fn build_nar_based_store_path<'a>(
|
pub fn build_nar_based_store_path<'a>(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue