Fix handling directories with only one or two files
This commit is contained in:
parent
bfb04cab66
commit
d612144be1
|
@ -527,11 +527,12 @@ func pickFile(args []string, filters *filters, sort string, cache *fileCache, fo
|
||||||
fileList, fromCache := fileList(args, filters, sort, cache, formats)
|
fileList, fromCache := fileList(args, filters, sort, cache, formats)
|
||||||
|
|
||||||
fileCount := len(fileList)
|
fileCount := len(fileList)
|
||||||
|
|
||||||
if fileCount < 1 {
|
if fileCount < 1 {
|
||||||
return "", ErrNoMediaFound
|
return "", ErrNoMediaFound
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := rand.Int(rand.Reader, big.NewInt(int64(fileCount-2)))
|
r, err := rand.Int(rand.Reader, big.NewInt(int64(fileCount)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -542,9 +543,10 @@ func pickFile(args []string, filters *filters, sort string, cache *fileCache, fo
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < fileCount; i++ {
|
for i := 0; i < fileCount; i++ {
|
||||||
if val >= fileCount {
|
switch {
|
||||||
|
case val >= fileCount:
|
||||||
val = 0
|
val = 0
|
||||||
} else {
|
case val < fileCount-1:
|
||||||
val++
|
val++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ReleaseVersion string = "0.80.0"
|
ReleaseVersion string = "0.80.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in New Issue