diff options
| author | Shulhan <ms@kilabit.info> | 2022-03-12 01:10:39 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-03-12 01:10:39 +0700 |
| commit | c7744a9b8badcac26a0b9ef18fc6cae390f7b19e (patch) | |
| tree | eba624676a73677cc4afba1b6c66a9f27e47418c /ciigo.go | |
| parent | a19849f5a835edd478edfd2b6cf5584426841ec1 (diff) | |
| download | ciigo-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.go | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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) |
