Move walkPath() defers out to calling function, for more intuitive readability

This commit is contained in:
Seednode 2024-01-10 11:58:55 -06:00
parent 9b6d9464e6
commit d568d10e78
2 changed files with 9 additions and 6 deletions

View File

@ -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)
}

View File

@ -17,7 +17,7 @@ import (
const (
AllowedCharacters string = `^[A-z0-9.\-_]+$`
ReleaseVersion string = "5.0.2"
ReleaseVersion string = "5.0.3"
)
var (