Skip to content

Commit

Permalink
Set maximum write timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mjh1 committed Jan 25, 2024
1 parent 58cf59f commit 12c1ada
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions catalyst-uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ func run() int {
glog.Fatal(err)
}
// cmd line args
var timeout time.Duration

Check warning on line 28 in catalyst-uploader.go

View check run for this annotation

Codecov / codecov/patch

catalyst-uploader.go#L28

Added line #L28 was not covered by tests
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")

Check warning on line 30 in catalyst-uploader.go

View check run for this annotation

Codecov / codecov/patch

catalyst-uploader.go#L30

Added line #L30 was not covered by tests
flag.Parse()

// list enabled handlers and exit
Expand All @@ -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
}

Check warning on line 57 in catalyst-uploader.go

View check run for this annotation

Codecov / codecov/patch

catalyst-uploader.go#L54-L57

Added lines #L54 - L57 were not covered by tests

err = core.Upload(os.Stdin, uri, WaitBetweenWrites, timeout)

Check warning on line 59 in catalyst-uploader.go

View check run for this annotation

Codecov / codecov/patch

catalyst-uploader.go#L59

Added line #L59 was not covered by tests
if err != nil {
glog.Fatalf("Uploader failed for %s: %s", uri, err)
return 1
Expand Down

0 comments on commit 12c1ada

Please sign in to comment.