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:
parent
155f53b264
commit
174485038c
1 changed files with 14 additions and 17 deletions
|
@ -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{
|
||||
|
|
Loading…
Reference in a new issue