diff --git a/extractor/filesystem/extractor.go b/extractor/filesystem/extractor.go index d63b9d35..7f744f90 100644 --- a/extractor/filesystem/extractor.go +++ b/extractor/filesystem/extractor.go @@ -197,7 +197,23 @@ func RunFS(ctx context.Context, config *Config, wc *walkContext) ([]*extractor.I if len(wc.filesToExtract) > 0 { err = walkIndividualFiles(wc.fs, wc.filesToExtract, wc.handleFile) } else { + ticker := time.NewTicker(2 * time.Second) + quit := make(chan struct{}) + go func() { + for { + select { + case <-ticker.C: + wc.printStatus() + case <-quit: + ticker.Stop() + return + } + } + }() + err = internal.WalkDirUnsorted(wc.fs, ".", wc.handleFile) + + close(quit) } log.Infof("End status: %d dirs visited, %d inodes visited, %d Extract calls, %s elapsed", @@ -235,6 +251,8 @@ type walkContext struct { lastInodes int extractCalls int lastExtracts int + + currentPath string } func walkIndividualFiles(fsys scalibrfs.FS, paths []string, fn fs.WalkDirFunc) error { @@ -253,7 +271,7 @@ func walkIndividualFiles(fsys scalibrfs.FS, paths []string, fn fs.WalkDirFunc) e } func (wc *walkContext) handleFile(path string, d fs.DirEntry, fserr error) error { - wc.printStatus(path) + wc.currentPath = path wc.inodesVisited++ if wc.maxInodes > 0 && wc.inodesVisited > wc.maxInodes { @@ -456,14 +474,12 @@ func errToExtractorStatus(extractors []Extractor, foundInv map[string]bool, erro return result } -func (wc *walkContext) printStatus(path string) { - if time.Since(wc.lastStatus) < 2*time.Second { - return - } +func (wc *walkContext) printStatus() { 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(), - wc.extractCalls-wc.lastExtracts, path) + wc.extractCalls-wc.lastExtracts, wc.currentPath) + wc.lastStatus = time.Now() wc.lastInodes = wc.inodesVisited wc.lastExtracts = wc.extractCalls