Compare commits
No commits in common. "f0bcafb645c6c324fd214381e746fa3fdf77c9e9" and "9844f4a2e1184532e5db661e023ad4e47063285f" have entirely different histories.
f0bcafb645
...
9844f4a2e1
83
cmd/files.go
83
cmd/files.go
|
@ -27,12 +27,12 @@ type regexes struct {
|
|||
filename *regexp.Regexp
|
||||
}
|
||||
|
||||
// type scanStats struct {
|
||||
// filesMatched int
|
||||
// filesSkipped int
|
||||
// directoriesMatched int
|
||||
// directoriesSkipped int
|
||||
// }
|
||||
type scanStats struct {
|
||||
filesMatched int
|
||||
filesSkipped int
|
||||
directoriesMatched int
|
||||
directoriesSkipped int
|
||||
}
|
||||
|
||||
type scanStatsChannels struct {
|
||||
filesMatched chan int
|
||||
|
@ -322,21 +322,19 @@ Poll:
|
|||
}
|
||||
|
||||
func scanPaths(paths []string, sort string, index *fileIndex, formats types.Types) ([]string, error) {
|
||||
startTime := time.Now()
|
||||
|
||||
var list []string
|
||||
|
||||
var filesMatched int = 0
|
||||
var filesSkipped int = 0
|
||||
var directoriesMatched int = 0
|
||||
var directoriesSkipped int = 0
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
fileChannel := make(chan string)
|
||||
errorChannel := make(chan error)
|
||||
done := make(chan bool, 1)
|
||||
|
||||
stats := &scanStats{
|
||||
filesMatched: 0,
|
||||
filesSkipped: 0,
|
||||
directoriesMatched: 0,
|
||||
directoriesSkipped: 0,
|
||||
}
|
||||
|
||||
statsChannels := &scanStatsChannels{
|
||||
filesMatched: make(chan int),
|
||||
filesSkipped: make(chan int),
|
||||
|
@ -344,35 +342,9 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
|||
directoriesSkipped: make(chan int),
|
||||
}
|
||||
|
||||
go func() {
|
||||
for path := range fileChannel {
|
||||
list = append(list, path)
|
||||
}
|
||||
}()
|
||||
var wg sync.WaitGroup
|
||||
|
||||
go func() {
|
||||
for stat := range statsChannels.filesMatched {
|
||||
filesMatched += stat
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for stat := range statsChannels.filesSkipped {
|
||||
filesSkipped += stat
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for stat := range statsChannels.directoriesMatched {
|
||||
directoriesMatched += stat
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for stat := range statsChannels.directoriesSkipped {
|
||||
directoriesSkipped += stat
|
||||
}
|
||||
}()
|
||||
startTime := time.Now()
|
||||
|
||||
for i := 0; i < len(paths); i++ {
|
||||
wg.Add(1)
|
||||
|
@ -395,16 +367,21 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats types.Type
|
|||
wg.Wait()
|
||||
|
||||
done <- true
|
||||
|
||||
close(statsChannels.filesMatched)
|
||||
close(statsChannels.filesSkipped)
|
||||
close(statsChannels.directoriesMatched)
|
||||
close(statsChannels.directoriesSkipped)
|
||||
}()
|
||||
|
||||
Poll:
|
||||
for {
|
||||
select {
|
||||
case path := <-fileChannel:
|
||||
list = append(list, path)
|
||||
case stat := <-statsChannels.filesMatched:
|
||||
stats.filesMatched += stat
|
||||
case stat := <-statsChannels.filesSkipped:
|
||||
stats.filesSkipped += stat
|
||||
case stat := <-statsChannels.directoriesMatched:
|
||||
stats.directoriesMatched += stat
|
||||
case stat := <-statsChannels.directoriesSkipped:
|
||||
stats.directoriesSkipped += stat
|
||||
case err := <-errorChannel:
|
||||
return []string{}, err
|
||||
case <-done:
|
||||
|
@ -412,7 +389,7 @@ Poll:
|
|||
}
|
||||
}
|
||||
|
||||
if filesMatched < 1 {
|
||||
if stats.filesMatched < 1 {
|
||||
fmt.Println("No files matched")
|
||||
|
||||
return []string{}, nil
|
||||
|
@ -421,10 +398,10 @@ Poll:
|
|||
if Verbose {
|
||||
fmt.Printf("%s | INDEX: Selecting from %d/%d files across %d/%d directories in %s\n",
|
||||
time.Now().Format(logDate),
|
||||
filesMatched,
|
||||
filesMatched+filesSkipped,
|
||||
directoriesMatched,
|
||||
directoriesMatched+directoriesSkipped,
|
||||
stats.filesMatched,
|
||||
stats.filesMatched+stats.filesSkipped,
|
||||
stats.directoriesMatched,
|
||||
stats.directoriesMatched+stats.directoriesSkipped,
|
||||
time.Since(startTime),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
ReleaseVersion string = "2.7.0"
|
||||
ReleaseVersion string = "2.6.0"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
BIN
default.pgo
BIN
default.pgo
Binary file not shown.
Loading…
Reference in New Issue