From 4a4ed2dce4ea4d9448d5aa03ea4040af202d2520 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Mon, 6 Jan 2025 02:51:20 +0700 Subject: all: ignore error when scanning for file markups When listing the file markups, if the node is symlink (either file or directory) and target its not exist, continue to the next node instead of returning error. The same is true for directory that cannot be opened, probably due to broken symlink or permission. --- ciigo.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ciigo.go b/ciigo.go index 5069252..4ae8a7b 100644 --- a/ciigo.go +++ b/ciigo.go @@ -162,10 +162,8 @@ func listFileMarkups(dir string, excRE []*regexp.Regexp) ( d, err = os.Open(dir) if err != nil { - if os.IsPermission(err) { - return nil, nil - } - return nil, fmt.Errorf(`%s: %w`, logp, err) + log.Printf(`%s: %s`, logp, err) + return nil, nil } fis, err = d.Readdir(0) @@ -186,7 +184,9 @@ func listFileMarkups(dir string, excRE []*regexp.Regexp) ( if fi.Mode()&os.ModeSymlink == os.ModeSymlink { fi, err = os.Stat(filePath) if err != nil { - return nil, fmt.Errorf(`%s: %w`, logp, err) + // Broken symlink. + log.Printf(`%s: %s`, logp, err) + continue } } -- cgit v1.3