Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions extractor/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"regexp"
"slices"
"strings"
"sync"
"time"

"github.com/gobwas/glob"
Expand Down Expand Up @@ -327,6 +328,7 @@ func RunFS(ctx context.Context, config *Config, wc *walkContext) (inventory.Inve
}

type walkContext struct {
mu sync.Mutex
//nolint:containedctx
ctx context.Context
stats stats.Collector
Expand Down Expand Up @@ -405,6 +407,8 @@ func walkIndividualPaths(wc *walkContext) error {
}

func (wc *walkContext) handleFile(path string, d fs.DirEntry, fserr error) error {
wc.mu.Lock()
defer wc.mu.Unlock()
wc.currentPath = path

wc.inodesVisited++
Expand Down Expand Up @@ -520,6 +524,8 @@ func (wc *walkContext) handleFile(path string, d fs.DirEntry, fserr error) error
}

func (wc *walkContext) postHandleFile(path string, d fs.DirEntry) {
wc.mu.Lock()
defer wc.mu.Unlock()
if len(wc.gitignores) > 0 && d.Type().IsDir() {
// Remove .gitignores that applied to this directory.
wc.gitignores = wc.gitignores[:len(wc.gitignores)-1]
Expand Down Expand Up @@ -741,6 +747,8 @@ func createFileErrorsForPlugin(errorMap map[string]error) []*plugin.FileError {
}

func (wc *walkContext) printStatus() {
wc.mu.Lock()
defer wc.mu.Unlock()
log.Infof("Status: new inodes: %d, %.1f inodes/s, new extract calls: %d, path: %q\n",
wc.inodesVisited-wc.lastInodes,
float64(wc.inodesVisited-wc.lastInodes)/time.Since(wc.lastStatus).Seconds(),
Expand Down
Loading