pickFile now iterates through entire file list, instead of stopping after an arbitrary number
This commit is contained in:
parent
2274c51e84
commit
297c561fab
14
cmd/files.go
14
cmd/files.go
|
@ -495,10 +495,18 @@ func pickFile(args []string, filters *Filters, sort string, fileCache *[]string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < maxRetries; i++ {
|
fileCount := len(fileList) - 1
|
||||||
i := rand.Intn(len(fileList))
|
|
||||||
|
|
||||||
filePath := fileList[i]
|
r := rand.Intn(fileCount)
|
||||||
|
|
||||||
|
for i := 0; i < fileCount; i++ {
|
||||||
|
if r > fileCount {
|
||||||
|
r = 0
|
||||||
|
} else {
|
||||||
|
r++
|
||||||
|
}
|
||||||
|
|
||||||
|
filePath := fileList[r]
|
||||||
|
|
||||||
if !Cache {
|
if !Cache {
|
||||||
isImage, err := isImage(filePath)
|
isImage, err := isImage(filePath)
|
||||||
|
|
|
@ -17,9 +17,6 @@ const (
|
||||||
// avoid hitting default open file descriptor limits (1024)
|
// avoid hitting default open file descriptor limits (1024)
|
||||||
maxDirectoryScans MaxConcurrency = 32
|
maxDirectoryScans MaxConcurrency = 32
|
||||||
maxFileScans MaxConcurrency = 256
|
maxFileScans MaxConcurrency = 256
|
||||||
|
|
||||||
// number of times pickFile() will check for a valid file
|
|
||||||
maxRetries int = 10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Concurrency struct {
|
type Concurrency struct {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "0.20.6"
|
var Version = "0.20.7"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(versionCmd)
|
rootCmd.AddCommand(versionCmd)
|
||||||
|
|
Loading…
Reference in New Issue