aboutsummaryrefslogtreecommitdiff
path: root/ciigo.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-03-12 01:10:39 +0700
committerShulhan <ms@kilabit.info>2022-03-12 01:10:39 +0700
commitc7744a9b8badcac26a0b9ef18fc6cae390f7b19e (patch)
treeeba624676a73677cc4afba1b6c66a9f27e47418c /ciigo.go
parenta19849f5a835edd478edfd2b6cf5584426841ec1 (diff)
downloadciigo-c7744a9b8badcac26a0b9ef18fc6cae390f7b19e.tar.xz
all: check for excluded file before processing sub directory
Previously, if the file path match with one of the excluded pattern, we keep processing the sub directory to find the markup files. This may cause an error "too many open files" if excluded directory contains many sub directory and/or files. This changes fix this issue by checking the path with excluded pattern first before diving into sub directory.
Diffstat (limited to 'ciigo.go')
-rw-r--r--ciigo.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/ciigo.go b/ciigo.go
index a6029cb..94e0f4a 100644
--- a/ciigo.go
+++ b/ciigo.go
@@ -291,6 +291,10 @@ func listFileMarkups(dir string, excRE []*regexp.Regexp) (
name := fi.Name()
filePath := filepath.Join(dir, name)
+ if isExcluded(filePath, excRE) {
+ continue
+ }
+
if fi.IsDir() {
if name[0] == '.' {
// Skip any directory start with '.'.
@@ -313,9 +317,6 @@ func listFileMarkups(dir string, excRE []*regexp.Regexp) (
if fi.Size() == 0 {
continue
}
- if isExcluded(filePath, excRE) {
- continue
- }
fmarkup, err := newFileMarkup(filePath, fi)
if err != nil {
return nil, fmt.Errorf("%s: %s: %w", logp, filePath, err)