From 646c962e5db2da0ed1acb7388048ffc4f146a927 Mon Sep 17 00:00:00 2001 From: Seednode Date: Fri, 5 Jan 2024 20:03:49 -0600 Subject: [PATCH] Add 1 microsecond delay to each call to walkPath() to fix incorrect filesMatched stat --- cmd/files.go | 13 +++++-------- cmd/root.go | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cmd/files.go b/cmd/files.go index 92e685a..fe3dfe5 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -248,7 +248,7 @@ func walkPath(path string, fileChannel chan<- string, stats *scanStats, limit ch }() errorChannel := make(chan error) - done := make(chan bool, 1) + done := make(chan bool) nodes, err := os.ReadDir(path) if err != nil { @@ -328,7 +328,9 @@ func walkPath(path string, fileChannel chan<- string, stats *scanStats, limit ch go func() { wg.Wait() - done <- true + time.Sleep(1 * time.Microsecond) + + close(done) }() Poll: @@ -443,11 +445,6 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type go func() { wg.Wait() - // Without this delay, occasionally a single file is missed when indexing, - // presumably due to a timing issue with closing the done channel. - // Pending a proper fix. - time.Sleep((100 * time.Millisecond)) - close(done) }() @@ -468,7 +465,7 @@ Poll: filesMatched+filesSkipped, directoriesMatched, directoriesMatched+directoriesSkipped, - time.Since(startTime)-100*time.Millisecond, + time.Since(startTime), ) } diff --git a/cmd/root.go b/cmd/root.go index ea559e4..5afbc9c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -14,7 +14,7 @@ import ( const ( AllowedCharacters string = `^[A-z0-9.\-_]+$` - ReleaseVersion string = "3.9.0" + ReleaseVersion string = "3.9.1" ) var (