From 12c1adabe87511ddb340d04d27275b1217c6d53a Mon Sep 17 00:00:00 2001 From: Max Holland Date: Thu, 25 Jan 2024 11:21:17 +0000 Subject: [PATCH] Set maximum write timeout --- catalyst-uploader.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/catalyst-uploader.go b/catalyst-uploader.go index 629771f..ab4103c 100644 --- a/catalyst-uploader.go +++ b/catalyst-uploader.go @@ -25,8 +25,9 @@ func run() int { glog.Fatal(err) } // cmd line args + var timeout time.Duration describe := flag.Bool("j", false, "Describe supported storage services in JSON format and exit") - timeout := flag.Duration("t", 30*time.Second, "Upload timeout") + flag.DurationVar(&timeout, "t", 30*time.Second, "Upload timeout") flag.Parse() // list enabled handlers and exit @@ -50,7 +51,12 @@ func run() int { return 1 } - err = core.Upload(os.Stdin, uri, WaitBetweenWrites, *timeout) + const maxTimeout = 5 * time.Minute + if timeout > maxTimeout { + timeout = maxTimeout + } + + err = core.Upload(os.Stdin, uri, WaitBetweenWrites, timeout) if err != nil { glog.Fatalf("Uploader failed for %s: %s", uri, err) return 1