From aa7bdc1199bfbb69091dda942a82812257e30bc4 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 9 Jun 2023 18:22:25 +0300 Subject: refactor(tvix/store): use Arc instead of Box This allows us to blob services without closing them before putting them in a box. We currently need to use Arc<_>, not Rc<_>, because the GRPC wrappers require Sync. Change-Id: I679c5f06b62304f5b0456cfefe25a0a881de7c84 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8738 Reviewed-by: tazjin Tested-by: BuildkiteCI Autosubmit: flokli --- tvix/store/src/directoryservice/traverse.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'tvix/store/src/directoryservice') diff --git a/tvix/store/src/directoryservice/traverse.rs b/tvix/store/src/directoryservice/traverse.rs index c1c0c6f8df64..8dfccd4ffbfa 100644 --- a/tvix/store/src/directoryservice/traverse.rs +++ b/tvix/store/src/directoryservice/traverse.rs @@ -1,5 +1,6 @@ use super::DirectoryService; use crate::{proto::NamedNode, B3Digest, Error}; +use std::sync::Arc; use tracing::{instrument, warn}; /// This traverses from a (root) node to the given (sub)path, returning the Node @@ -11,7 +12,7 @@ use tracing::{instrument, warn}; /// clearly distinguish it from the BFS traversers. #[instrument(skip(directory_service))] pub fn traverse_to( - directory_service: &Box, + directory_service: Arc, node: crate::proto::node::Node, path: &std::path::Path, ) -> Result, Error> { @@ -91,7 +92,7 @@ mod tests { #[test] fn test_traverse_to() { - let mut directory_service = gen_directory_service(); + let directory_service = gen_directory_service(); let mut handle = directory_service.put_multiple_start(); handle @@ -121,7 +122,7 @@ mod tests { // traversal to an empty subpath should return the root node. { let resp = traverse_to( - &mut directory_service, + directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from(""), ) @@ -133,7 +134,7 @@ mod tests { // traversal to `keep` should return the node for DIRECTORY_WITH_KEEP { let resp = traverse_to( - &mut directory_service, + directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("keep"), ) @@ -145,7 +146,7 @@ mod tests { // traversal to `keep/.keep` should return the node for the .keep file { let resp = traverse_to( - &mut directory_service, + directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("keep/.keep"), ) @@ -157,7 +158,7 @@ mod tests { // traversal to `keep/.keep` should return the node for the .keep file { let resp = traverse_to( - &mut directory_service, + directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("/keep/.keep"), ) @@ -169,7 +170,7 @@ mod tests { // traversal to `void` should return None (doesn't exist) { let resp = traverse_to( - &mut directory_service, + directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("void"), ) @@ -181,7 +182,7 @@ mod tests { // traversal to `void` should return None (doesn't exist) { let resp = traverse_to( - &mut directory_service, + directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("//v/oid"), ) @@ -194,7 +195,7 @@ mod tests { // reached, as keep/.keep already is a file) { let resp = traverse_to( - &mut directory_service, + directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("keep/.keep/foo"), ) @@ -206,7 +207,7 @@ mod tests { // traversal to a subpath of '/' should return the root node. { let resp = traverse_to( - &mut directory_service, + directory_service.clone(), node_directory_complicated.clone(), &PathBuf::from("/"), ) -- cgit 1.4.1