about summary refs log tree commit diff
path: root/tvix/store/src/import.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-06-09T15·22+0300
committerclbot <clbot@tvl.fyi>2023-06-12T10·24+0000
commitaa7bdc1199bfbb69091dda942a82812257e30bc4 (patch)
tree933964562f5746274ef6df59cfa956aca73b0807 /tvix/store/src/import.rs
parent7725eb53ad67730e92a3839a6c10925c668e5586 (diff)
refactor(tvix/store): use Arc instead of Box r/6273
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 <tazjin@tvl.su>
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/store/src/import.rs')
-rw-r--r--tvix/store/src/import.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/tvix/store/src/import.rs b/tvix/store/src/import.rs
index d07ddfc41ea2..1e639e1d7cd0 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<super::Error> 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<dyn BlobService>,
+    blob_service: Arc<dyn BlobService>,
     directory_putter: &mut Box<dyn DirectoryPutter>,
     entry: &walkdir::DirEntry,
     maybe_directory: Option<proto::Directory>,
@@ -146,8 +147,8 @@ fn process_entry(
 /// naming scheme.
 #[instrument(skip(blob_service, directory_service), fields(path=?p))]
 pub fn ingest_path<P: AsRef<Path> + Debug>(
-    blob_service: &Box<dyn BlobService>,
-    directory_service: &Box<dyn DirectoryService>,
+    blob_service: Arc<dyn BlobService>,
+    directory_service: Arc<dyn DirectoryService>,
     p: P,
 ) -> Result<proto::node::Node, Error> {
     // Probe if the path points to a symlink. If it does, we process it manually,
@@ -199,7 +200,12 @@ pub fn ingest_path<P: AsRef<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);