about summary refs log tree commit diff
path: root/tvix/store/src/proto
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src/proto')
-rw-r--r--tvix/store/src/proto/mod.rs23
-rw-r--r--tvix/store/src/proto/tests/pathinfo.rs10
2 files changed, 19 insertions, 14 deletions
diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs
index a982d71f8886..4b5bf4f59479 100644
--- a/tvix/store/src/proto/mod.rs
+++ b/tvix/store/src/proto/mod.rs
@@ -140,6 +140,19 @@ impl PathInfo {
                         );
                     }
                 }
+
+                // If the Deriver field is populated, ensure it parses to a
+                // [store_path::StorePath].
+                // We can't check for it to *not* end with .drv, as the .drv files produced by
+                // recursive Nix end with multiple .drv suffixes, and only one is popped when
+                // converting to this field.
+                if let Some(deriver) = &narinfo.deriver {
+                    store_path::StorePath::from_name_and_digest(
+                        deriver.name.clone(),
+                        &deriver.digest,
+                    )
+                    .map_err(ValidatePathInfoError::InvalidDeriverField)?;
+                }
             }
         }
 
@@ -156,16 +169,6 @@ impl PathInfo {
             }
         };
 
-        // If the Deriver field is populated, ensure it parses to a
-        // [store_path::StorePath].
-        // We can't check for it to *not* end with .drv, as the .drv files produced by
-        // recursive Nix end with multiple .drv suffixes, and only one is popped when
-        // converting to this field.
-        if let Some(deriver) = &self.deriver {
-            store_path::StorePath::from_name_and_digest(deriver.name.clone(), &deriver.digest)
-                .map_err(ValidatePathInfoError::InvalidDeriverField)?;
-        }
-
         // return the root nix path
         Ok(root_nix_path)
     }
diff --git a/tvix/store/src/proto/tests/pathinfo.rs b/tvix/store/src/proto/tests/pathinfo.rs
index 03094ed734ce..392d5d8127b4 100644
--- a/tvix/store/src/proto/tests/pathinfo.rs
+++ b/tvix/store/src/proto/tests/pathinfo.rs
@@ -266,10 +266,11 @@ fn validate_symlink_target_null_byte_invalid() {
 /// Create a PathInfo with a correct deriver field and ensure it succeeds.
 #[test]
 fn validate_valid_deriver() {
-    let mut path_info = PATH_INFO_WITHOUT_NARINFO.clone();
+    let mut path_info = PATH_INFO_WITH_NARINFO.clone();
 
     // add a valid deriver
-    path_info.deriver = Some(crate::proto::StorePath {
+    let narinfo = path_info.narinfo.as_mut().unwrap();
+    narinfo.deriver = Some(crate::proto::StorePath {
         name: "foo".to_string(),
         digest: DUMMY_OUTPUT_HASH.clone(),
     });
@@ -280,10 +281,11 @@ fn validate_valid_deriver() {
 /// Create a PathInfo with a broken deriver field and ensure it fails.
 #[test]
 fn validate_invalid_deriver() {
-    let mut path_info = PATH_INFO_WITHOUT_NARINFO.clone();
+    let mut path_info = PATH_INFO_WITH_NARINFO.clone();
 
     // add a broken deriver (invalid digest)
-    path_info.deriver = Some(crate::proto::StorePath {
+    let narinfo = path_info.narinfo.as_mut().unwrap();
+    narinfo.deriver = Some(crate::proto::StorePath {
         name: "foo".to_string(),
         digest: vec![].into(),
     });