diff options
author | Florian Klink <flokli@flokli.de> | 2023-09-21T22·08+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-09-22T12·12+0000 |
commit | d8ef0cfb4a859af7e33828b013356412d02532da (patch) | |
tree | eb802886533a3cb1a1aa2ddb638413701330fa42 | |
parent | 7c9a52e3ee99ad14b453a1929c2a5a3a53d51505 (diff) |
docs(tvix/castore): rename traverse_to -> descend_to r/6628
With the move of this code out into castore it has become apparent this is a general descent inside the castore. Concerns like making sure the whole Directory closure has been fetched/is fetched initially is nothing this layer needs to worry about. We can handle this during substitution of a new PathInfo, once there's store composition. Closes b/270. Change-Id: I661ed08e54bc81478e032cfb9abeb23e5b337fbe Reviewed-on: https://cl.tvl.fyi/c/depot/+/9373 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com>
-rw-r--r-- | tvix/cli/src/tvix_store_io.rs | 2 | ||||
-rw-r--r-- | tvix/store/src/directoryservice/mod.rs | 2 | ||||
-rw-r--r-- | tvix/store/src/directoryservice/traverse.rs | 28 |
3 files changed, 14 insertions, 18 deletions
diff --git a/tvix/cli/src/tvix_store_io.rs b/tvix/cli/src/tvix_store_io.rs index 1ea718f1a188..ef112858b1bc 100644 --- a/tvix/cli/src/tvix_store_io.rs +++ b/tvix/cli/src/tvix_store_io.rs @@ -90,7 +90,7 @@ impl TvixStoreIO { let directory_service = self.directory_service.clone(); let sub_path = sub_path.to_owned(); let task = self.tokio_handle.spawn(async move { - directoryservice::traverse_to(directory_service, root_node, &sub_path).await + directoryservice::descend_to(directory_service, root_node, &sub_path).await }); Ok(self.tokio_handle.block_on(task).unwrap()?) diff --git a/tvix/store/src/directoryservice/mod.rs b/tvix/store/src/directoryservice/mod.rs index 09210dfed8e8..3b26f4baf79b 100644 --- a/tvix/store/src/directoryservice/mod.rs +++ b/tvix/store/src/directoryservice/mod.rs @@ -14,7 +14,7 @@ pub use self::from_addr::from_addr; pub use self::grpc::GRPCDirectoryService; pub use self::memory::MemoryDirectoryService; pub use self::sled::SledDirectoryService; -pub use self::traverse::traverse_to; +pub use self::traverse::descend_to; /// The base trait all Directory services need to implement. /// This is a simple get and put of [crate::proto::Directory], returning their diff --git a/tvix/store/src/directoryservice/traverse.rs b/tvix/store/src/directoryservice/traverse.rs index 0489c4458163..5043439e9de5 100644 --- a/tvix/store/src/directoryservice/traverse.rs +++ b/tvix/store/src/directoryservice/traverse.rs @@ -3,14 +3,10 @@ use crate::{proto::NamedNode, B3Digest, Error}; use std::{os::unix::ffi::OsStrExt, sync::Arc}; use tracing::{instrument, warn}; -/// This traverses from a (root) node to the given (sub)path, returning the Node +/// This descends from a (root) node to the given (sub)path, returning the Node /// at that path, or none, if there's nothing at that path. -/// TODO: Do we want to use [DirectoryService.get_recursive] to do less lookups? -/// Or do we consider this to be a non-issue due to store composition and local caching? -/// TODO: the name of this function (and mod) is a bit bad, because it doesn't -/// clearly distinguish it from the BFS traversers. #[instrument(skip(directory_service))] -pub async fn traverse_to( +pub async fn descend_to( directory_service: Arc<dyn DirectoryService>, root_node: crate::proto::node::Node, path: &std::path::Path, @@ -93,10 +89,10 @@ mod tests { utils::gen_directory_service, }; - use super::traverse_to; + use super::descend_to; #[tokio::test] - async fn test_traverse_to() { + async fn test_descend_to() { let directory_service = gen_directory_service(); let mut handle = directory_service.put_multiple_start(); @@ -128,7 +124,7 @@ mod tests { // traversal to an empty subpath should return the root node. { - let resp = traverse_to( + let resp = descend_to( directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from(""), @@ -141,7 +137,7 @@ mod tests { // traversal to `keep` should return the node for DIRECTORY_WITH_KEEP { - let resp = traverse_to( + let resp = descend_to( directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("keep"), @@ -154,7 +150,7 @@ mod tests { // traversal to `keep/.keep` should return the node for the .keep file { - let resp = traverse_to( + let resp = descend_to( directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("keep/.keep"), @@ -167,7 +163,7 @@ mod tests { // traversal to `keep/.keep` should return the node for the .keep file { - let resp = traverse_to( + let resp = descend_to( directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("/keep/.keep"), @@ -180,7 +176,7 @@ mod tests { // traversal to `void` should return None (doesn't exist) { - let resp = traverse_to( + let resp = descend_to( directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("void"), @@ -193,7 +189,7 @@ mod tests { // traversal to `void` should return None (doesn't exist) { - let resp = traverse_to( + let resp = descend_to( directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("//v/oid"), @@ -207,7 +203,7 @@ mod tests { // traversal to `keep/.keep/404` should return None (the path can't be // reached, as keep/.keep already is a file) { - let resp = traverse_to( + let resp = descend_to( directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("keep/.keep/foo"), @@ -220,7 +216,7 @@ mod tests { // traversal to a subpath of '/' should return the root node. { - let resp = traverse_to( + let resp = descend_to( directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("/"), |