From d8ef0cfb4a859af7e33828b013356412d02532da Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 22 Sep 2023 01:08:13 +0300 Subject: docs(tvix/castore): rename traverse_to -> descend_to 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 Reviewed-by: Connor Brewster --- tvix/store/src/directoryservice/mod.rs | 2 +- tvix/store/src/directoryservice/traverse.rs | 28 ++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-) (limited to 'tvix/store/src') 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, 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("/"), -- cgit 1.4.1