diff --git a/cmd/files.go b/cmd/files.go index 360c8fa..3832364 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -527,11 +527,12 @@ func pickFile(args []string, filters *filters, sort string, cache *fileCache, fo fileList, fromCache := fileList(args, filters, sort, cache, formats) fileCount := len(fileList) + if fileCount < 1 { 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 { return "", err } @@ -542,9 +543,10 @@ func pickFile(args []string, filters *filters, sort string, cache *fileCache, fo } for i := 0; i < fileCount; i++ { - if val >= fileCount { + switch { + case val >= fileCount: val = 0 - } else { + case val < fileCount-1: val++ } diff --git a/cmd/root.go b/cmd/root.go index 42ea417..293ce25 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( ) const ( - ReleaseVersion string = "0.80.0" + ReleaseVersion string = "0.80.1" ) var (