about summary refs log tree commit diff
path: root/tvix/store/src/store_io.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-06-09T09·26+0300
committerclbot <clbot@tvl.fyi>2023-06-12T10·24+0000
commit7725eb53ad67730e92a3839a6c10925c668e5586 (patch)
tree82b8abf8e52630039d2a0cd3ae8b251c32e863bd /tvix/store/src/store_io.rs
parent6f85dbfc06c4fa96deb968cfeb7e98ba36e95043 (diff)
refactor(tvix/store): use Box<dyn DirectoryService> r/6272
Once we support configuring services at runtime, we don't know what
DirectoryService we're using at compile time.

This also means, we can't explicitly use the is_closed method from
GRPCPutter, without making it part of the DirectoryPutter itself.

Change-Id: Icd2a1ec4fc5649a6cd15c9cc7db4c2b473630431
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8727
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/store_io.rs')
-rw-r--r--tvix/store/src/store_io.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/tvix/store/src/store_io.rs b/tvix/store/src/store_io.rs
index 3820931e281f..ee302f3b58ba 100644
--- a/tvix/store/src/store_io.rs
+++ b/tvix/store/src/store_io.rs
@@ -29,17 +29,17 @@ use crate::{
 /// This is to both cover cases of syntactically valid store paths, that exist
 /// on the filesystem (still managed by Nix), as well as being able to read
 /// files outside store paths.
-pub struct TvixStoreIO<DS: DirectoryService, PS: PathInfoService> {
+pub struct TvixStoreIO<PS: PathInfoService> {
     blob_service: Box<dyn BlobService>,
-    directory_service: DS,
+    directory_service: Box<dyn DirectoryService>,
     path_info_service: PS,
     std_io: StdIO,
 }
 
-impl<DS: DirectoryService + Clone, PS: PathInfoService> TvixStoreIO<DS, PS> {
+impl<PS: PathInfoService> TvixStoreIO<PS> {
     pub fn new(
         blob_service: Box<dyn BlobService>,
-        directory_service: DS,
+        directory_service: Box<dyn DirectoryService>,
         path_info_service: PS,
     ) -> Self {
         Self {
@@ -104,12 +104,9 @@ impl<DS: DirectoryService + Clone, PS: PathInfoService> TvixStoreIO<DS, PS> {
             .expect("error during import_path");
 
         // Render the NAR
-        let (nar_size, nar_sha256) = calculate_size_and_sha256(
-            &root_node,
-            &self.blob_service,
-            self.directory_service.clone(),
-        )
-        .expect("error during nar calculation"); // TODO: handle error
+        let (nar_size, nar_sha256) =
+            calculate_size_and_sha256(&root_node, &self.blob_service, &self.directory_service)
+                .expect("error during nar calculation"); // TODO: handle error
 
         // For given NAR sha256 digest and name, return the new [StorePath] this would have.
         let nar_hash_with_mode =
@@ -175,7 +172,7 @@ fn calculate_nar_based_store_path(nar_sha256_digest: &[u8; 32], name: &str) -> S
     build_regular_ca_path(name, &nar_hash_with_mode, Vec::<String>::new(), false).unwrap()
 }
 
-impl<DS: DirectoryService + Clone, PS: PathInfoService> EvalIO for TvixStoreIO<DS, PS> {
+impl<PS: PathInfoService> EvalIO for TvixStoreIO<PS> {
     #[instrument(skip(self), ret, err)]
     fn path_exists(&self, path: &Path) -> Result<bool, io::Error> {
         if let Ok((store_path, sub_path)) =