Skip to content

Commit 1551d16

Browse files
SCALIBR Teamcopybara-github
authored andcommitted
Automated Code Change
PiperOrigin-RevId: 840666036
1 parent 414f009 commit 1551d16

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

extractor/filesystem/filesystem.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"regexp"
2727
"slices"
2828
"strings"
29+
"sync"
2930
"time"
3031

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

329330
type walkContext struct {
331+
mu sync.Mutex
330332
//nolint:containedctx
331333
ctx context.Context
332334
stats stats.Collector
@@ -405,6 +407,8 @@ func walkIndividualPaths(wc *walkContext) error {
405407
}
406408

407409
func (wc *walkContext) handleFile(path string, d fs.DirEntry, fserr error) error {
410+
wc.mu.Lock()
411+
defer wc.mu.Unlock()
408412
wc.currentPath = path
409413

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

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

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

0 commit comments

Comments
 (0)