From: Matt Joiner Date: Wed, 17 May 2023 02:13:16 +0000 (+1000) Subject: Fix overflow in average download rate X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;ds=sidebyside;h=f643521f1d20f5c1f68c3c40be672dc61cffbe91;p=btrtrc.git Fix overflow in average download rate --- diff --git a/cmd/torrent/download.go b/cmd/torrent/download.go index 0ec4b990..cb3ca583 100644 --- a/cmd/torrent/download.go +++ b/cmd/torrent/download.go @@ -357,12 +357,12 @@ func downloadErr(flags downloadFlags) error { err = ctx.Err() } clientConnStats := client.ConnStats() - log.Printf("average download rate: %v", - humanize.Bytes(uint64( - time.Duration( - clientConnStats.BytesReadUsefulData.Int64(), - )*time.Second/time.Since(started), - ))) + log.Printf( + "average download rate: %v/s", + humanize.Bytes(uint64(float64( + clientConnStats.BytesReadUsefulData.Int64(), + )/time.Since(started).Seconds())), + ) if flags.Seed { if len(client.Torrents()) == 0 { log.Print("no torrents to seed")