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-09-02T17·23+0300
committerflokli <flokli@flokli.de>2023-09-02T20·08+0000
commit116a137be082547de08bd13382fc31e925ca6217 (patch)
tree93c9ec6a1209e9e80be4cdd125c198ec01600413 /tvix/store/src/store_io.rs
parent1e9d262ad595c3128cb048f544dcb194231e42f4 (diff)
refactor(tvix/store): implement rename for node::Node r/6546
This returns a node with a new name.

Change-Id: Iebcab537f8dd63d826b9841d4d0181fcb941afdd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9211
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to '')
-rw-r--r--tvix/store/src/store_io.rs18
1 files changed, 2 insertions, 16 deletions
diff --git a/tvix/store/src/store_io.rs b/tvix/store/src/store_io.rs
index 615d1f50f4..024d90576f 100644
--- a/tvix/store/src/store_io.rs
+++ b/tvix/store/src/store_io.rs
@@ -131,26 +131,12 @@ impl TvixStoreIO {
             build_regular_ca_path(name, &nar_hash_with_mode, Vec::<String>::new(), false).unwrap();
 
         // assemble a new root_node with a name that is derived from the nar hash.
-        let renamed_root_node = {
-            let name = output_path.to_string().into_bytes().into();
-
-            match root_node {
-                crate::proto::node::Node::Directory(n) => {
-                    crate::proto::node::Node::Directory(crate::proto::DirectoryNode { name, ..n })
-                }
-                crate::proto::node::Node::File(n) => {
-                    crate::proto::node::Node::File(crate::proto::FileNode { name, ..n })
-                }
-                crate::proto::node::Node::Symlink(n) => {
-                    crate::proto::node::Node::Symlink(crate::proto::SymlinkNode { name, ..n })
-                }
-            }
-        };
+        let root_node = root_node.rename(output_path.to_string().into_bytes().into());
 
         // assemble the [crate::proto::PathInfo] object.
         let path_info = crate::proto::PathInfo {
             node: Some(crate::proto::Node {
-                node: Some(renamed_root_node),
+                node: Some(root_node),
             }),
             // There's no reference scanning on path contents ingested like this.
             references: vec![],