From d568d10e78433bf19de8904c925d1575339ed553 Mon Sep 17 00:00:00 2001 From: Seednode Date: Wed, 10 Jan 2024 11:58:55 -0600 Subject: [PATCH] Move walkPath() defers out to calling function, for more intuitive readability --- cmd/files.go | 13 ++++++++----- cmd/root.go | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/files.go b/cmd/files.go index 30735df..8fa2cb5 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -241,10 +241,6 @@ func hasSupportedFiles(path string, formats types.Types) (bool, error) { } func walkPath(path string, fileChannel chan<- string, wg1 *sync.WaitGroup, stats *scanStats, limit chan struct{}, formats types.Types, errorChannel chan<- error) { - defer func() { - wg1.Done() - }() - limit <- struct{}{} defer func() { @@ -297,7 +293,12 @@ func walkPath(path string, fileChannel chan<- string, wg1 *sync.WaitGroup, stats case node.IsDir() && Recursive: wg1.Add(1) - walkPath(fullPath, fileChannel, wg1, stats, limit, formats, errorChannel) + go func() { + defer wg1.Done() + + walkPath(fullPath, fileChannel, wg1, stats, limit, formats, errorChannel) + }() + case !node.IsDir() && !skipFiles: path, err := normalizePath(fullPath) if err != nil { @@ -421,6 +422,8 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type wg1.Add(1) go func(i int) { + defer wg1.Done() + walkPath(paths[i], fileChannel, &wg1, stats, limit, formats, errorChannel) }(i) } diff --git a/cmd/root.go b/cmd/root.go index d95dfb4..d227ff6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,7 +17,7 @@ import ( const ( AllowedCharacters string = `^[A-z0-9.\-_]+$` - ReleaseVersion string = "5.0.2" + ReleaseVersion string = "5.0.3" ) var (