Skip to content

Commit f364e10

Browse files
authored
Ignore symlinks discovered in findFilesRecursively (#890)
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
1 parent c979552 commit f364e10

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

pkg/action/path.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package action
33
import (
44
"context"
55
"fmt"
6+
"io/fs"
67
"os"
78
"path/filepath"
89
"strings"
@@ -46,6 +47,26 @@ func findFilesRecursively(ctx context.Context, rootPath string) ([]string, error
4647
return nil
4748
}
4849

50+
// Ignore symlinked directories like regular directories
51+
if info.Type()&fs.ModeSymlink == fs.ModeSymlink {
52+
logger.Debugf("attempting to resolve symlink: %s", path)
53+
eval, err := filepath.EvalSymlinks(path)
54+
if err != nil {
55+
logger.Errorf("eval: %s: %s", path, err)
56+
return nil
57+
}
58+
fi, err := os.Stat(eval)
59+
if err != nil {
60+
logger.Errorf("stat: %s: %s", path, err)
61+
return nil
62+
}
63+
if fi.IsDir() {
64+
logger.Debugf("ignoring symlinked directory: %s", path)
65+
return nil
66+
}
67+
path = eval
68+
}
69+
4970
files = append(files, path)
5071
return nil
5172
})

0 commit comments

Comments
 (0)