refactor(nix-compat/store_path): make StorePath generic on S
Similar to how cl/12253 already did this for `Signature`, we apply the same logic to `StorePath`. `StorePathRef<'a>'` is now a `StorePath<&'a str>`, and there's less redundant code for the two different implementation. `.as_ref()` returns a `StorePathRef<'_>`, `.to_owned()` gives a `StorePath<String>` (for now). I briefly thought about only publicly exporting `StorePath<String>` as `StorePath`, but the diff is not too large and this will make it easier to gradually introduce more flexibility in which store paths to accept. Also, remove some silliness in `StorePath::from_absolute_path_full`, which now doesn't allocate anymore. Change-Id: Ife8843857a1a0a3a99177ca997649fd45b8198e6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12258 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
parent
413135b925
commit
2beabe968c
15 changed files with 301 additions and 315 deletions
|
|
@ -112,7 +112,7 @@ mod import_builtins {
|
|||
|
||||
use crate::tvix_store_io::TvixStoreIO;
|
||||
use nix_compat::nixhash::{CAHash, NixHash};
|
||||
use nix_compat::store_path::StorePath;
|
||||
use nix_compat::store_path::StorePathRef;
|
||||
use sha2::Digest;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tvix_eval::builtins::coerce_value_to_path;
|
||||
|
|
@ -377,16 +377,16 @@ mod import_builtins {
|
|||
}
|
||||
})?;
|
||||
|
||||
let path_exists = if let Ok((store_path, sub_path)) = StorePath::from_absolute_path_full(p)
|
||||
{
|
||||
if !sub_path.as_os_str().is_empty() {
|
||||
false
|
||||
let path_exists =
|
||||
if let Ok((store_path, sub_path)) = StorePathRef::from_absolute_path_full(p) {
|
||||
if !sub_path.as_os_str().is_empty() {
|
||||
false
|
||||
} else {
|
||||
state.store_path_exists(store_path.as_ref()).await?
|
||||
}
|
||||
} else {
|
||||
state.store_path_exists(store_path.as_ref()).await?
|
||||
}
|
||||
} else {
|
||||
false
|
||||
};
|
||||
false
|
||||
};
|
||||
|
||||
if !path_exists {
|
||||
return Err(ImportError::PathNotInStore(p.into()).into());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue