cmd/dl.go | 10 +++++++++- diff --git a/cmd/dl.go b/cmd/dl.go index 39c59797f5a190516d93de554b494cccc7bd961456830245cfbca3f83560974c..f275de0bf95e91989d105753f383527ea72ee034d56719adf277116a095dbfd8 100644 --- a/cmd/dl.go +++ b/cmd/dl.go @@ -64,9 +64,17 @@ } if resp.StatusCode != http.StatusOK { log.Fatalln("status code:", resp.Status) } + var sizeExpected uint64 + if *size == 0 { + if resp.ContentLength > 0 { + sizeExpected = uint64(resp.ContentLength) + } + } else { + sizeExpected = uint64(*size) + } var w io.Writer if *progress { - bar := Progress{w: os.Stdout, now: time.Now(), total: uint64(*size)} + bar := Progress{w: os.Stdout, now: time.Now(), total: sizeExpected} bar.next = bar.now.Add(ProgressPeriod) w = &bar } else {