mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
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>
This commit is contained in:
parent
c802c3089c
commit
e1ea0056b9
@ -62,6 +62,7 @@ func (p symlinkChain) Locate(pattern string) ([]string, error) {
|
|||||||
return candidates, nil
|
return candidates, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var filenames []string
|
||||||
found := make(map[string]bool)
|
found := make(map[string]bool)
|
||||||
for len(candidates) > 0 {
|
for len(candidates) > 0 {
|
||||||
candidate := candidates[0]
|
candidate := candidates[0]
|
||||||
@ -70,6 +71,7 @@ func (p symlinkChain) Locate(pattern string) ([]string, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
found[candidate] = true
|
found[candidate] = true
|
||||||
|
filenames = append(filenames, candidate)
|
||||||
|
|
||||||
target, err := symlinks.Resolve(candidate)
|
target, err := symlinks.Resolve(candidate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -88,11 +90,6 @@ func (p symlinkChain) Locate(pattern string) ([]string, error) {
|
|||||||
candidates = append(candidates, target)
|
candidates = append(candidates, target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var filenames []string
|
|
||||||
for f := range found {
|
|
||||||
filenames = append(filenames, f)
|
|
||||||
}
|
|
||||||
return filenames, nil
|
return filenames, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user