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/import.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tvix/store/src/import.rs') diff --git a/tvix/store/src/import.rs b/tvix/store/src/import.rs index d07ddfc41e..1e639e1d7c 100644 --- a/tvix/store/src/import.rs +++ b/tvix/store/src/import.rs @@ -1,6 +1,7 @@ use crate::blobservice::BlobService; use crate::directoryservice::DirectoryService; use crate::{directoryservice::DirectoryPutter, proto}; +use std::sync::Arc; use std::{ collections::HashMap, fmt::Debug, @@ -57,7 +58,7 @@ impl From for Error { // It assumes the caller adds returned nodes to the directories it assembles. #[instrument(skip_all, fields(entry.file_type=?&entry.file_type(),entry.path=?entry.path()))] fn process_entry( - blob_service: &Box, + blob_service: Arc, directory_putter: &mut Box, entry: &walkdir::DirEntry, maybe_directory: Option, @@ -146,8 +147,8 @@ fn process_entry( /// naming scheme. #[instrument(skip(blob_service, directory_service), fields(path=?p))] pub fn ingest_path + Debug>( - blob_service: &Box, - directory_service: &Box, + blob_service: Arc, + directory_service: Arc, p: P, ) -> Result { // Probe if the path points to a symlink. If it does, we process it manually, @@ -199,7 +200,12 @@ pub fn ingest_path + Debug>( } }; - let node = process_entry(blob_service, &mut directory_putter, &entry, maybe_directory)?; + let node = process_entry( + blob_service.clone(), + &mut directory_putter, + &entry, + maybe_directory, + )?; if entry.depth() == 0 { return Ok(node); -- cgit 1.4.1