From 8d6cf09c63340a678309aaa5867e95f854f60051 Mon Sep 17 00:00:00 2001 From: Mauricio Villegas Date: Sun, 6 Oct 2019 00:57:15 +0200 Subject: [PATCH] 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 --- pkg/sympath/walk.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/sympath/walk.go b/pkg/sympath/walk.go index b2500284a..24f4d340b 100644 --- a/pkg/sympath/walk.go +++ b/pkg/sympath/walk.go @@ -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 {