fix(pkg/sympath): symwalk process symlinks only with its un-resolved path

When a symlink is encountered, only replace the resolved info, don't walk the resolved symlink path since the walk should be as if path
were the actual linked to path.

Signed-off-by: Mauricio Villegas <mauricio_ville@yahoo.com>
pull/6586/head
Mauricio Villegas 6 years ago
parent 4e8063b103
commit 8d6cf09c63
No known key found for this signature in database
GPG Key ID: F039394A9C7972FD

@ -63,7 +63,9 @@ func readDirNames(dirname string) ([]string, error) {
// symwalk recursively descends path, calling walkFn.
func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
// Recursively walk symlinked directories.
// When a symlink is encountered, only replace the resolved info, don't
// walk the resolved symlink path since the walk should be as if path
// were the actual linked to path.
if IsSymlink(info) {
resolved, err := filepath.EvalSymlinks(path)
if err != nil {
@ -72,9 +74,6 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
if info, err = os.Lstat(resolved); err != nil {
return err
}
if err := symwalk(resolved, info, walkFn); err != nil && err != filepath.SkipDir {
return err
}
}
if err := walkFn(path, info, nil); err != nil {

Loading…
Cancel
Save