diff options
Diffstat (limited to 'tvix/store/src/pathinfoservice/fs/mod.rs')
-rw-r--r-- | tvix/store/src/pathinfoservice/fs/mod.rs | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/tvix/store/src/pathinfoservice/fs/mod.rs b/tvix/store/src/pathinfoservice/fs/mod.rs index aa64b1c01f16..ea30a2f6477c 100644 --- a/tvix/store/src/pathinfoservice/fs/mod.rs +++ b/tvix/store/src/pathinfoservice/fs/mod.rs @@ -1,10 +1,10 @@ use futures::stream::BoxStream; use futures::StreamExt; +use nix_compat::store_path::StorePathRef; use tonic::async_trait; use tvix_castore::fs::{RootNodes, TvixStoreFs}; -use tvix_castore::proto as castorepb; -use tvix_castore::Error; use tvix_castore::{blobservice::BlobService, directoryservice::DirectoryService}; +use tvix_castore::{Error, Node, PathComponent}; use super::PathInfoService; @@ -20,9 +20,9 @@ pub fn make_fs<BS, DS, PS>( show_xattr: bool, ) -> TvixStoreFs<BS, DS, RootNodesWrapper<PS>> where - BS: AsRef<dyn BlobService> + Send + Clone + 'static, - DS: AsRef<dyn DirectoryService> + Send + Clone + 'static, - PS: AsRef<dyn PathInfoService> + Send + Sync + Clone + 'static, + BS: BlobService + Send + Clone + 'static, + DS: DirectoryService + Send + Clone + 'static, + PS: PathInfoService + Send + Sync + Clone + 'static, { TvixStoreFs::new( blob_service, @@ -46,35 +46,31 @@ pub struct RootNodesWrapper<T>(pub(crate) T); #[async_trait] impl<T> RootNodes for RootNodesWrapper<T> where - T: AsRef<dyn PathInfoService> + Send + Sync, + T: PathInfoService + Send + Sync, { - async fn get_by_basename(&self, name: &[u8]) -> Result<Option<castorepb::node::Node>, Error> { - let Ok(store_path) = nix_compat::store_path::StorePath::from_bytes(name) else { + async fn get_by_basename(&self, name: &PathComponent) -> Result<Option<Node>, Error> { + let Ok(store_path) = StorePathRef::from_bytes(name.as_ref()) else { return Ok(None); }; Ok(self .0 - .as_ref() .get(*store_path.digest()) .await? - .map(|path_info| { - path_info - .node - .expect("missing root node") - .node - .expect("empty node") - })) + .map(|path_info| path_info.node)) } - fn list(&self) -> BoxStream<Result<castorepb::node::Node, Error>> { - Box::pin(self.0.as_ref().list().map(|result| { + fn list(&self) -> BoxStream<Result<(PathComponent, Node), Error>> { + Box::pin(self.0.list().map(|result| { result.map(|path_info| { - path_info - .node - .expect("missing root node") - .node - .expect("empty node") + let basename = path_info.store_path.to_string(); + ( + basename + .as_str() + .try_into() + .expect("Tvix bug: StorePath must be PathComponent"), + path_info.node, + ) }) })) } |