refactor(nix-compat/store_path): drop build_nar_based_store_path

This is the only (remaining) occurence of it, and not really
more code than just calling store_path::build_ca_path with
`CAHash::Nar(NixHash::Sha256(…))`, especially considering we need the
CAHash in the PathInfo struct later anyways - so let's remove this
function.

Change-Id: Ia82212086062c366e0280ca0823d9e68a3f91d3a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12632
Reviewed-by: edef <edef@edef.eu>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2024-10-16 02:41:05 +03:00 committed by clbot
parent 1277b0c088
commit a94414e7ff
2 changed files with 5 additions and 17 deletions

View file

@ -99,11 +99,13 @@ where
// Ask for the NAR size and sha256
let (nar_size, nar_sha256) = nar_calculation_service.calculate_nar(&root_node).await?;
let ca = CAHash::Nar(NixHash::Sha256(nar_sha256));
// Calculate the output path. This might still fail, as some names are illegal.
// FUTUREWORK: express the `name` at the type level to be valid and move the conversion
// at the caller level.
let output_path: StorePath<String> = store_path::build_nar_based_store_path(&nar_sha256, name)
.map_err(|_| {
let output_path: StorePath<String> =
store_path::build_ca_path(name, &ca, std::iter::empty::<&str>(), false).map_err(|_| {
std::io::Error::new(
std::io::ErrorKind::InvalidData,
format!("invalid name: {}", name),
@ -122,7 +124,7 @@ where
nar_sha256,
signatures: vec![],
deriver: None,
ca: Some(CAHash::Nar(NixHash::Sha256(nar_sha256))),
ca: Some(ca),
})
.await?)
}