about summary refs log tree commit diff
path: root/tvix/nar-bridge/pkg
diff options
context:
space:
mode:
authorConnor Brewster <cbrewster@hey.com>2023-09-17T11·52-0500
committerConnor Brewster <cbrewster@hey.com>2023-09-17T13·55+0000
commit4ac6423b26170668f99ef2351091d5e1352b298a (patch)
tree69d9cf194432a564278e01485ea46bd0a69b034b /tvix/nar-bridge/pkg
parent84aa07a736b4327400bc2183e670cf29bb0304df (diff)
refactor(tvix/nar-bridge): Clean up directory popping loop r/6603
This change got lost in the rebases in cl/9348. There's unnecessary
`break`/`continues` that can be replaced by moving the conditional into
the for loop condition.

Change-Id: I559e21087630b05e483f768ab59f8067961a2eae
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9352
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/nar-bridge/pkg')
-rw-r--r--tvix/nar-bridge/pkg/reader/reader.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/tvix/nar-bridge/pkg/reader/reader.go b/tvix/nar-bridge/pkg/reader/reader.go
index 9ff7b3fedb09..04e1e6f2ae69 100644
--- a/tvix/nar-bridge/pkg/reader/reader.go
+++ b/tvix/nar-bridge/pkg/reader/reader.go
@@ -195,16 +195,11 @@ func (r *Reader) Import(
 
 			// We don't need to worry about the root node case, because we can only finish the root "/"
 			// If we're at the end of the NAR reader (covered by the EOF check)
-			for {
-				// We never want to pop the root directory until we're completely done.
-				if len(stack) > 1 && !strings.HasPrefix(hdr.Path, stack[len(stack)-1].path+"/") {
-					err := popFromStack()
-					if err != nil {
-						return nil, fmt.Errorf("unable to pop from stack: %w", err)
-					}
-					continue
+			for len(stack) > 1 && !strings.HasPrefix(hdr.Path, stack[len(stack)-1].path+"/") {
+				err := popFromStack()
+				if err != nil {
+					return nil, fmt.Errorf("unable to pop from stack: %w", err)
 				}
-				break
 			}
 
 			if hdr.Type == nar.TypeSymlink {