fix: check for error on resolving symlink

job-suspend
sammyette 2023-02-07 10:42:36 -04:00
parent efc69ab769
commit 6b27d14f45
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 6 additions and 5 deletions

View File

@ -151,11 +151,12 @@ func matchPath(query string) ([]string, string) {
files, _ := os.ReadDir(path)
for _, entry := range files {
// should we handle errors here?
file, _ := entry.Info()
fileInfo, err := entry.Info()
if err == nil && fileInfo.Mode() & os.ModeSymlink != 0 {
path, _ := filepath.EvalSymlinks(filepath.Join(path, file.Name()))
file, _ = os.Lstat(path)
file, err := entry.Info()
if err == nil && file.Mode() & os.ModeSymlink != 0 {
path, err := filepath.EvalSymlinks(filepath.Join(path, file.Name()))
if err == nil {
file, err = os.Lstat(path)
}
}
if strings.HasPrefix(file.Name(), baseName) {