Skip to content

Commit e1ea005

Browse files
committed
Fix bug in sorting of symlink chain
Since we use a map to keep track of the elements of a symlink chain the construction of the final list of located elements is not stable. This change constructs the output as this is being discovered and as such maintains the original ordering. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent c802c30 commit e1ea005

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

internal/lookup/symlinks.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (p symlinkChain) Locate(pattern string) ([]string, error) {
6262
return candidates, nil
6363
}
6464

65+
var filenames []string
6566
found := make(map[string]bool)
6667
for len(candidates) > 0 {
6768
candidate := candidates[0]
@@ -70,6 +71,7 @@ func (p symlinkChain) Locate(pattern string) ([]string, error) {
7071
continue
7172
}
7273
found[candidate] = true
74+
filenames = append(filenames, candidate)
7375

7476
target, err := symlinks.Resolve(candidate)
7577
if err != nil {
@@ -88,11 +90,6 @@ func (p symlinkChain) Locate(pattern string) ([]string, error) {
8890
candidates = append(candidates, target)
8991
}
9092
}
91-
92-
var filenames []string
93-
for f := range found {
94-
filenames = append(filenames, f)
95-
}
9693
return filenames, nil
9794
}
9895

0 commit comments

Comments
 (0)