From 3d6e7b04933bfbe017213043081a1dd44db5cc6a Mon Sep 17 00:00:00 2001 From: Seednode Date: Fri, 28 Oct 2022 21:08:08 -0500 Subject: [PATCH] Added limit on file checking retries --- cmd/files.go | 2 +- cmd/root.go | 3 +++ cmd/version.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/files.go b/cmd/files.go index c23344b..d8e10bf 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -495,7 +495,7 @@ func pickFile(args []string, filters *Filters, sort string, fileCache *[]string) } } - for true { + for i := 0; i < maxRetries; i++ { i := rand.Intn(len(fileList)) filePath := fileList[i] diff --git a/cmd/root.go b/cmd/root.go index 444cdf4..ac2bee6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,6 +17,9 @@ const ( // avoid hitting default open file descriptor limits (1024) maxDirectoryScans MaxConcurrency = 32 maxFileScans MaxConcurrency = 256 + + // number of times pickFile() will check for a valid file + maxRetries int = 10 ) type Concurrency struct { diff --git a/cmd/version.go b/cmd/version.go index c02a2af..19bcbf8 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.20.4" +var Version = "0.20.5" func init() { rootCmd.AddCommand(versionCmd)