about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix')
-rw-r--r--tvix/glue/src/tvix_store_io.rs1
-rw-r--r--tvix/store/src/bin/tvix-store.rs23
-rw-r--r--tvix/store/src/import.rs10
3 files changed, 19 insertions, 15 deletions
diff --git a/tvix/glue/src/tvix_store_io.rs b/tvix/glue/src/tvix_store_io.rs
index 45bcf0df3ae8..1277a1d97792 100644
--- a/tvix/glue/src/tvix_store_io.rs
+++ b/tvix/glue/src/tvix_store_io.rs
@@ -276,6 +276,7 @@ impl EvalIO for TvixStoreIO {
         let output_path = self.tokio_handle.block_on(async {
             tvix_store::import::import_path_as_nar_ca(
                 path,
+                tvix_store::import::path_to_name(path)?,
                 &self.blob_service,
                 &self.directory_service,
                 &self.path_info_service,
diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs
index 9b07117d71ff..ecee8d78f3b7 100644
--- a/tvix/store/src/bin/tvix-store.rs
+++ b/tvix/store/src/bin/tvix-store.rs
@@ -305,16 +305,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
                         let path_info_service = path_info_service.clone();
 
                         async move {
-                            let resp = tvix_store::import::import_path_as_nar_ca(
-                                path,
-                                blob_service,
-                                directory_service,
-                                path_info_service,
-                            )
-                            .await;
-                            if let Ok(output_path) = resp {
-                                // If the import was successful, print the path to stdout.
-                                println!("{}", output_path.to_absolute_path());
+                            if let Ok(name) = tvix_store::import::path_to_name(&path) {
+                                let resp = tvix_store::import::import_path_as_nar_ca(
+                                    &path,
+                                    name,
+                                    blob_service,
+                                    directory_service,
+                                    path_info_service,
+                                )
+                                .await;
+                                if let Ok(output_path) = resp {
+                                    // If the import was successful, print the path to stdout.
+                                    println!("{}", output_path.to_absolute_path());
+                                }
                             }
                         }
                     })
diff --git a/tvix/store/src/import.rs b/tvix/store/src/import.rs
index 84c73e15544c..588a0108931e 100644
--- a/tvix/store/src/import.rs
+++ b/tvix/store/src/import.rs
@@ -13,7 +13,7 @@ use crate::{
     proto::{nar_info, NarInfo, PathInfo},
 };
 
-fn log_node(node: &Node, path: &Path) {
+pub fn log_node(node: &Node, path: &Path) {
     match node {
         Node::Directory(directory_node) => {
             debug!(
@@ -86,9 +86,10 @@ pub fn derive_nar_ca_path_info(nar_size: u64, nar_sha256: [u8; 32], root_node: N
 
 /// Ingest the given path [`path`] and register the resulting output path in the
 /// [`PathInfoService`] as a recursive fixed output NAR.
-#[instrument(skip_all, fields(path=?path), err)]
+#[instrument(skip_all, fields(store_name=name, path=?path), err)]
 pub async fn import_path_as_nar_ca<BS, DS, PS, P>(
     path: P,
+    name: &str,
     blob_service: BS,
     directory_service: DS,
     path_info_service: PS,
@@ -106,9 +107,8 @@ where
     let (nar_size, nar_sha256) = path_info_service.as_ref().calculate_nar(&root_node).await?;
 
     // Calculate the output path. This might still fail, as some names are illegal.
-    // FUTUREWORK: take `name` as a parameter here and enforce the validity of the name
-    // at the type level.
-    let name = path_to_name(path.as_ref())?;
+    // FUTUREWORK: express the `name` at the type level to be valid and move the conversion
+    // at the caller level.
     let output_path = store_path::build_nar_based_store_path(&nar_sha256, name).map_err(|_| {
         std::io::Error::new(
             std::io::ErrorKind::InvalidData,