]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix overflow in average download rate
authorMatt Joiner <anacrolix@gmail.com>
Wed, 17 May 2023 02:13:16 +0000 (12:13 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 17 May 2023 02:13:16 +0000 (12:13 +1000)
cmd/torrent/download.go

index 0ec4b99088250bc37cae52daf60c9791155519bc..cb3ca583b022975fc02682858a5ab423b6f83a94 100644 (file)
@@ -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")