refactor(tvix/nar-bridge): inline assemblePathInfo

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
This commit is contained in:
Florian Klink 2023-10-03 12:42:18 +03:00 committed by clbot
parent 155f53b264
commit 174485038c

View file

@ -97,20 +97,6 @@ func (r *Reader) Import(
return nil 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 { getBasename := func(p string) string {
// extract the basename. In case of "/", replace with empty string. // extract the basename. In case of "/", replace with empty string.
basename := path.Base(p) 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. // Stack is empty. We now either have a regular or symlink root node,
// assemble pathInfo with these and return. // or we encountered at least one directory assemble pathInfo with these and
pi := assemblePathInfo() // 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 { if rootFile != nil {
pi.Node = &castorev1pb.Node{ pi.Node = &castorev1pb.Node{
Node: &castorev1pb.Node_File{ Node: &castorev1pb.Node_File{