about summary refs log tree commit diff
path: root/tvix/castore/src/directoryservice/directory_graph.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-08-17T14·40+0300
committerclbot <clbot@tvl.fyi>2024-08-18T16·49+0000
commit96832c04116fb5a3be2d314659e701a3669ec65d (patch)
treefca0c6fae125dabba212be6b8ebb2de10224c223 /tvix/castore/src/directoryservice/directory_graph.rs
parent76839683a7ab0453afcdc3374a5cc80cca2f9510 (diff)
feat(tvix/castore): add Directory::try_from_iter() r/8511
This provides a batched variant to construct a Directory, which reuses
the previously calculated size.

Checking and inserting code is factored out into a check_insert_node
function, taking the current size as a parameter and returning the new
size.

Change-Id: Ia6c2970a0c12181b7c40e63cf7ce8c93298ea37c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12225
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src/directoryservice/directory_graph.rs')
-rw-r--r--tvix/castore/src/directoryservice/directory_graph.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/tvix/castore/src/directoryservice/directory_graph.rs b/tvix/castore/src/directoryservice/directory_graph.rs
index d8d8e7370510..017cef024059 100644
--- a/tvix/castore/src/directoryservice/directory_graph.rs
+++ b/tvix/castore/src/directoryservice/directory_graph.rs
@@ -290,16 +290,16 @@ mod tests {
     use super::{DirectoryGraph, LeavesToRootValidator, RootToLeavesValidator};
 
     lazy_static! {
-        pub static ref BROKEN_PARENT_DIRECTORY: Directory = {
-            let mut dir = Directory::new();
-            dir.add(
-                "foo".try_into().unwrap(),
-                Node::Directory{
-                    digest: DIRECTORY_A.digest(),
-                    size: DIRECTORY_A.size() + 42, // wrong!
-                }).unwrap();
-            dir
-        };
+        pub static ref BROKEN_PARENT_DIRECTORY: Directory =
+            Directory::try_from_iter([
+                (
+                    "foo".try_into().unwrap(),
+                    Node::Directory{
+                        digest: DIRECTORY_A.digest(),
+                        size: DIRECTORY_A.size() + 42, // wrong!
+                    }
+                )
+            ]).unwrap();
     }
 
     #[rstest]