about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-10-03T09·42+0300
committerclbot <clbot@tvl.fyi>2023-10-05T06·11+0000
commit174485038c15643d3002c0f4773d74480daa8a77 (patch)
tree762d0d027ef077603bc64ca52317558133602fe0
parent155f53b264436c012efc272b45f6fb4532c09338 (diff)
refactor(tvix/nar-bridge): inline assemblePathInfo r/6691
This is only called once.

Change-Id: I342443b8d04050929733fc84d5f36cd64060afe3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9525
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
-rw-r--r--tvix/nar-bridge/pkg/reader/reader.go31
1 files changed, 14 insertions, 17 deletions
diff --git a/tvix/nar-bridge/pkg/reader/reader.go b/tvix/nar-bridge/pkg/reader/reader.go
index ff9804934ff4..764766b621fb 100644
--- a/tvix/nar-bridge/pkg/reader/reader.go
+++ b/tvix/nar-bridge/pkg/reader/reader.go
@@ -97,20 +97,6 @@ func (r *Reader) Import(
 		return nil
 	}
 
-	// Assemble a PathInfo struct, the Node is populated later.
-	assemblePathInfo := func() *storev1pb.PathInfo {
-		return &storev1pb.PathInfo{
-			Node:       nil,
-			References: [][]byte{},
-			Narinfo: &storev1pb.NARInfo{
-				NarSize:        uint64(r.hrSha256.BytesWritten()),
-				NarSha256:      r.hrSha256.Sum(nil),
-				Signatures:     []*storev1pb.NARInfo_Signature{},
-				ReferenceNames: []string{},
-			},
-		}
-	}
-
 	getBasename := func(p string) string {
 		// extract the basename. In case of "/", replace with empty string.
 		basename := path.Base(p)
@@ -151,9 +137,20 @@ func (r *Reader) Import(
 
 				}
 
-				// Stack is empty. We now either have a regular or symlink root node, or we encountered at least one directory.
-				// assemble pathInfo with these and return.
-				pi := assemblePathInfo()
+				// Stack is empty. We now either have a regular or symlink root node,
+				// or we encountered at least one directory assemble pathInfo with these and
+				// return.
+				pi := &storev1pb.PathInfo{
+					Node:       nil,
+					References: [][]byte{},
+					Narinfo: &storev1pb.NARInfo{
+						NarSize:        uint64(r.hrSha256.BytesWritten()),
+						NarSha256:      r.hrSha256.Sum(nil),
+						Signatures:     []*storev1pb.NARInfo_Signature{},
+						ReferenceNames: []string{},
+					},
+				}
+
 				if rootFile != nil {
 					pi.Node = &castorev1pb.Node{
 						Node: &castorev1pb.Node_File{