aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/index
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/index')
-rw-r--r--pkg/index/filters.go4
-rw-r--r--pkg/index/index.go9
2 files changed, 8 insertions, 5 deletions
diff --git a/pkg/index/filters.go b/pkg/index/filters.go
index 920d5df..bd9df54 100644
--- a/pkg/index/filters.go
+++ b/pkg/index/filters.go
@@ -50,10 +50,10 @@ func ParseFilter(s string) (DocFilter, error) {
}
return NewMaxFilesizeFilter(size), nil
case "ExcludeName", "ExcludeFilename":
- // FIXME: support escaped commas
+ // TODO: support escaped commas
return NewExcludeFilenameFilter(strings.Split(param, ",")), nil
case "IncludeName", "IncludeFilename":
- // FIXME: support escaped commas
+ // TODO: support escaped commas
return NewIncludeFilenameFilter(strings.Split(param, ",")), nil
case "ExcludeParent":
return NewExcludeParentFilter(param), nil
diff --git a/pkg/index/index.go b/pkg/index/index.go
index cfa4138..50f642e 100644
--- a/pkg/index/index.go
+++ b/pkg/index/index.go
@@ -12,6 +12,7 @@ import (
"slices"
"strings"
"sync"
+ "sync/atomic"
"time"
"github.com/goccy/go-yaml"
@@ -383,21 +384,23 @@ func ParseDoc(path string, opts ParseOpts) (*Document, error) {
return doc, nil
}
-func ParseDocs(paths []string, numWorkers uint, opts ParseOpts) map[string]*Document {
+func ParseDocs(paths []string, numWorkers uint, opts ParseOpts) (map[string]*Document, uint64) {
jobs := make(chan string, numWorkers)
results := make(chan *Document, numWorkers)
docs := make(map[string]*Document, len(paths))
wg := &sync.WaitGroup{}
+ errCnt := &atomic.Uint64{}
wg.Add(int(numWorkers))
for range numWorkers {
go func(jobs <-chan string, results chan<- *Document, wg *sync.WaitGroup) {
for path := range jobs {
doc, err := ParseDoc(path, opts)
if err != nil {
- slog.Error("Error occured while parsing file",
+ slog.Warn("Error occured while parsing file",
slog.String("path", path), slog.String("err", err.Error()),
)
+ errCnt.Add(1)
continue
}
@@ -423,7 +426,7 @@ func ParseDocs(paths []string, numWorkers uint, opts ParseOpts) map[string]*Docu
docs[doc.Path] = doc
}
- return docs
+ return docs, errCnt.Load()
}
func init() {