about summary refs log tree commit diff
path: root/tvix/nar-bridge/pkg/pathinfosvc/server.go
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-10-09T22·53+0200
committerclbot <clbot@tvl.fyi>2023-10-10T18·02+0000
commit6fe34b7ba03c5e2406a0659da651134e675a55d6 (patch)
treef9bd44e10746beae6b957efa00cd23774c4e979b /tvix/nar-bridge/pkg/pathinfosvc/server.go
parent2699b61052cdf5c92760a66a9dd1e2620e479fc8 (diff)
refactor(tvix/nar-bridge): use castorev1pb.RenamedNode r/6771
We can use the helper to rename the node.

Change-Id: Id8defea7e5ebbd43d7b7a9b2992c62084e1828ec
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9601
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: Brian McGee <brian@bmcgee.ie>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/nar-bridge/pkg/pathinfosvc/server.go')
-rw-r--r--tvix/nar-bridge/pkg/pathinfosvc/server.go11
1 files changed, 1 insertions, 10 deletions
diff --git a/tvix/nar-bridge/pkg/pathinfosvc/server.go b/tvix/nar-bridge/pkg/pathinfosvc/server.go
index c452237f2693..a271745039f1 100644
--- a/tvix/nar-bridge/pkg/pathinfosvc/server.go
+++ b/tvix/nar-bridge/pkg/pathinfosvc/server.go
@@ -247,16 +247,7 @@ func (p *PathInfoServiceServer) Get(ctx context.Context, getPathInfoRequest *sto
 		panic(err)
 	}
 
-	// set the root name in all three cases.
-	if node := pathInfo.Node.GetDirectory(); node != nil {
-		node.Name = []byte(outPath.String())
-	} else if node := pathInfo.Node.GetFile(); node != nil {
-		node.Name = []byte(outPath.String())
-	} else if node := pathInfo.Node.GetSymlink(); node != nil {
-		node.Name = []byte(outPath.String())
-	} else {
-		panic("node may not be nil")
-	}
+	pathInfo.Node = castorev1pb.RenamedNode(pathInfo.Node, outPath.String())
 
 	// run Validate on the PathInfo, more as an additional sanity check our code is sound,
 	// to make sure we populated everything properly, before returning it.