feat(nix-compat/store_path): build_ca_path may fail

Change-Id: Ia74ee870f38b7966501458bace541092256c3213
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10509
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2023-12-31 18:54:44 +02:00 committed by clbot
parent 20c98a51bf
commit fdd7817aad
3 changed files with 18 additions and 5 deletions

View file

@ -115,14 +115,14 @@ pub fn build_ca_path<'a, S: AsRef<str>, I: IntoIterator<Item = S>>(
}
/// For given NAR sha256 digest and name, return the new [StorePathRef] this
/// would have.
/// would have, or an error, in case the name is invalid.
pub fn build_nar_based_store_path<'a>(
nar_sha256_digest: &[u8; 32],
name: &'a str,
) -> StorePathRef<'a> {
) -> Result<StorePathRef<'a>, BuildStorePathError> {
let nar_hash_with_mode = CAHash::Nar(NixHash::Sha256(nar_sha256_digest.to_owned()));
build_ca_path(name, &nar_hash_with_mode, Vec::<String>::new(), false).unwrap()
build_ca_path(name, &nar_hash_with_mode, Vec::<String>::new(), false)
}
/// This builds an input-addressed store path.