Rework filewalk function yet again
This commit is contained in:
parent
3e6ad89ea4
commit
9d789cb439
52
cmd/files.go
52
cmd/files.go
|
@ -326,16 +326,16 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
||||||
|
|
||||||
var list []string
|
var list []string
|
||||||
|
|
||||||
var filesMatched int = 0
|
var filesMatched int
|
||||||
var filesSkipped int = 0
|
var filesSkipped int
|
||||||
var directoriesMatched int = 0
|
var directoriesMatched int
|
||||||
var directoriesSkipped int = 0
|
var directoriesSkipped int
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
fileChannel := make(chan string)
|
fileChannel := make(chan string)
|
||||||
errorChannel := make(chan error)
|
errorChannel := make(chan error)
|
||||||
done := make(chan bool, 1)
|
done := make(chan bool)
|
||||||
|
|
||||||
statsChannels := &scanStatsChannels{
|
statsChannels := &scanStatsChannels{
|
||||||
filesMatched: make(chan int),
|
filesMatched: make(chan int),
|
||||||
|
@ -345,32 +345,57 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for path := range fileChannel {
|
for {
|
||||||
|
select {
|
||||||
|
case path := <-fileChannel:
|
||||||
list = append(list, path)
|
list = append(list, path)
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for stat := range statsChannels.filesMatched {
|
for {
|
||||||
|
select {
|
||||||
|
case stat := <-statsChannels.filesMatched:
|
||||||
filesMatched += stat
|
filesMatched += stat
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for stat := range statsChannels.filesSkipped {
|
for {
|
||||||
|
select {
|
||||||
|
case stat := <-statsChannels.filesSkipped:
|
||||||
filesSkipped += stat
|
filesSkipped += stat
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for stat := range statsChannels.directoriesMatched {
|
for {
|
||||||
|
select {
|
||||||
|
case stat := <-statsChannels.directoriesMatched:
|
||||||
directoriesMatched += stat
|
directoriesMatched += stat
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for stat := range statsChannels.directoriesSkipped {
|
for {
|
||||||
|
select {
|
||||||
|
case stat := <-statsChannels.directoriesSkipped:
|
||||||
directoriesSkipped += stat
|
directoriesSkipped += stat
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -394,12 +419,7 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
||||||
go func() {
|
go func() {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
done <- true
|
close(done)
|
||||||
|
|
||||||
close(statsChannels.filesMatched)
|
|
||||||
close(statsChannels.filesSkipped)
|
|
||||||
close(statsChannels.directoriesMatched)
|
|
||||||
close(statsChannels.directoriesSkipped)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
Poll:
|
Poll:
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ReleaseVersion string = "2.7.1"
|
ReleaseVersion string = "2.7.2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in New Issue