diff --git a/cmd/files.go b/cmd/files.go index 0528cde..c23344b 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -495,13 +495,11 @@ func pickFile(args []string, filters *Filters, sort string, fileCache *[]string) } } - rand.Seed(time.Now().UnixNano()) - rand.Shuffle(len(fileList), func(i, j int) { fileList[i], fileList[j] = fileList[j], fileList[i] }) + for true { + i := rand.Intn(len(fileList)) - for i := 0; i < len(fileList); i++ { filePath := fileList[i] - // If not caching, check for valid images just before serving, to speed up scanning if !Cache { isImage, err := isImage(filePath) if err != nil { diff --git a/cmd/version.go b/cmd/version.go index 8c31a1b..5832493 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.20.2" +var Version = "0.20.3" func init() { rootCmd.AddCommand(versionCmd) diff --git a/cmd/web.go b/cmd/web.go index c050c34..6a06094 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -7,6 +7,7 @@ package cmd import ( "fmt" "io" + "math/rand" "net/http" "net/url" "os" @@ -498,6 +499,8 @@ func ServePage(args []string) error { re := regexp.MustCompile(`(.+)([0-9]{3})(\..+)`) + rand.Seed(time.Now().UnixNano()) + fileCache := []string{} http.Handle("/", serveHtmlHandler(paths, *re, &fileCache))