Compare commits
No commits in common. "9b6d9464e613b3c143acf09adbf43f2e1be24134" and "431de92bbbe7452e4b1aa24a5c034e10d28be928" have entirely different histories.
9b6d9464e6
...
431de92bbb
46
cmd/files.go
46
cmd/files.go
|
@ -240,9 +240,9 @@ 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, wg0 *sync.WaitGroup, stats *scanStats, limit chan struct{}, formats types.Types, errorChannel chan<- error) {
|
||||
defer func() {
|
||||
wg1.Done()
|
||||
wg0.Done()
|
||||
}()
|
||||
|
||||
limit <- struct{}{}
|
||||
|
@ -283,21 +283,24 @@ func walkPath(path string, fileChannel chan<- string, wg1 *sync.WaitGroup, stats
|
|||
stats.directoriesMatched <- 1
|
||||
}
|
||||
|
||||
var wg2 sync.WaitGroup
|
||||
var wg1 sync.WaitGroup
|
||||
|
||||
wg1.Add(1)
|
||||
go func() {
|
||||
defer wg1.Done()
|
||||
for _, node := range nodes {
|
||||
wg2.Add(1)
|
||||
wg1.Add(1)
|
||||
|
||||
go func(node fs.DirEntry) {
|
||||
defer wg2.Done()
|
||||
defer wg1.Done()
|
||||
|
||||
fullPath := filepath.Join(path, node.Name())
|
||||
|
||||
switch {
|
||||
case node.IsDir() && Recursive:
|
||||
wg1.Add(1)
|
||||
wg0.Add(1)
|
||||
|
||||
walkPath(fullPath, fileChannel, wg1, stats, limit, formats, errorChannel)
|
||||
walkPath(fullPath, fileChannel, wg0, stats, limit, formats, errorChannel)
|
||||
case !node.IsDir() && !skipFiles:
|
||||
path, err := normalizePath(fullPath)
|
||||
if err != nil {
|
||||
|
@ -320,8 +323,9 @@ func walkPath(path string, fileChannel chan<- string, wg1 *sync.WaitGroup, stats
|
|||
}
|
||||
}(node)
|
||||
}
|
||||
}()
|
||||
|
||||
wg2.Wait()
|
||||
wg1.Wait()
|
||||
}
|
||||
|
||||
func scanPaths(paths []string, sort string, index *fileIndex, formats types.Types, errorChannel chan<- error) []string {
|
||||
|
@ -342,11 +346,7 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
|||
|
||||
var list []string
|
||||
|
||||
var wg0 sync.WaitGroup
|
||||
|
||||
wg0.Add(1)
|
||||
go func() {
|
||||
defer wg0.Done()
|
||||
for {
|
||||
select {
|
||||
case path := <-fileChannel:
|
||||
|
@ -357,10 +357,7 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
|||
}
|
||||
}()
|
||||
|
||||
wg0.Add(1)
|
||||
go func() {
|
||||
defer wg0.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
case stat := <-stats.filesMatched:
|
||||
|
@ -371,10 +368,7 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
|||
}
|
||||
}()
|
||||
|
||||
wg0.Add(1)
|
||||
go func() {
|
||||
defer wg0.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
case stat := <-stats.filesSkipped:
|
||||
|
@ -385,10 +379,7 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
|||
}
|
||||
}()
|
||||
|
||||
wg0.Add(1)
|
||||
go func() {
|
||||
defer wg0.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
case stat := <-stats.directoriesMatched:
|
||||
|
@ -399,10 +390,7 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
|||
}
|
||||
}()
|
||||
|
||||
wg0.Add(1)
|
||||
go func() {
|
||||
defer wg0.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
case stat := <-stats.directoriesSkipped:
|
||||
|
@ -415,22 +403,20 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
|||
|
||||
limit := make(chan struct{}, Concurrency)
|
||||
|
||||
var wg1 sync.WaitGroup
|
||||
var wg0 sync.WaitGroup
|
||||
|
||||
for i := 0; i < len(paths); i++ {
|
||||
wg1.Add(1)
|
||||
wg0.Add(1)
|
||||
|
||||
go func(i int) {
|
||||
walkPath(paths[i], fileChannel, &wg1, stats, limit, formats, errorChannel)
|
||||
walkPath(paths[i], fileChannel, &wg0, stats, limit, formats, errorChannel)
|
||||
}(i)
|
||||
}
|
||||
|
||||
wg1.Wait()
|
||||
wg0.Wait()
|
||||
|
||||
close(done)
|
||||
|
||||
wg0.Wait()
|
||||
|
||||
if Verbose {
|
||||
fmt.Printf("%s | INDEX: Selected %d/%d files across %d/%d directories in %s\n",
|
||||
time.Now().Format(logDate),
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
const (
|
||||
AllowedCharacters string = `^[A-z0-9.\-_]+$`
|
||||
ReleaseVersion string = "5.0.2"
|
||||
ReleaseVersion string = "5.0.0"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
Loading…
Reference in New Issue