Move walkPath() defers out to calling function, for more intuitive readability
This commit is contained in:
parent
9b6d9464e6
commit
d568d10e78
11
cmd/files.go
11
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) {
|
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{}{}
|
limit <- struct{}{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -297,7 +293,12 @@ func walkPath(path string, fileChannel chan<- string, wg1 *sync.WaitGroup, stats
|
||||||
case node.IsDir() && Recursive:
|
case node.IsDir() && Recursive:
|
||||||
wg1.Add(1)
|
wg1.Add(1)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer wg1.Done()
|
||||||
|
|
||||||
walkPath(fullPath, fileChannel, wg1, stats, limit, formats, errorChannel)
|
walkPath(fullPath, fileChannel, wg1, stats, limit, formats, errorChannel)
|
||||||
|
}()
|
||||||
|
|
||||||
case !node.IsDir() && !skipFiles:
|
case !node.IsDir() && !skipFiles:
|
||||||
path, err := normalizePath(fullPath)
|
path, err := normalizePath(fullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -421,6 +422,8 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
||||||
wg1.Add(1)
|
wg1.Add(1)
|
||||||
|
|
||||||
go func(i int) {
|
go func(i int) {
|
||||||
|
defer wg1.Done()
|
||||||
|
|
||||||
walkPath(paths[i], fileChannel, &wg1, stats, limit, formats, errorChannel)
|
walkPath(paths[i], fileChannel, &wg1, stats, limit, formats, errorChannel)
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AllowedCharacters string = `^[A-z0-9.\-_]+$`
|
AllowedCharacters string = `^[A-z0-9.\-_]+$`
|
||||||
ReleaseVersion string = "5.0.2"
|
ReleaseVersion string = "5.0.3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in New Issue