Print average download rate

This commit is contained in:
Matt Joiner 2021-10-14 23:14:10 +11:00
parent 181cbd3e52
commit 89e7e00c31
1 changed files with 8 additions and 0 deletions

View File

@ -347,6 +347,7 @@ func downloadErr(flags downloadFlags) error {
client.WriteStatus(w) client.WriteStatus(w)
}) })
err = addTorrents(client, flags) err = addTorrents(client, flags)
started := time.Now()
if err != nil { if err != nil {
return fmt.Errorf("adding torrents: %w", err) return fmt.Errorf("adding torrents: %w", err)
} }
@ -356,6 +357,13 @@ func downloadErr(flags downloadFlags) error {
} else { } else {
err = errors.New("y u no complete torrents?!") err = errors.New("y u no complete torrents?!")
} }
clientConnStats := client.ConnStats()
log.Printf("average download rate: %v",
humanize.Bytes(uint64(
time.Duration(
clientConnStats.BytesReadUsefulData.Int64(),
)*time.Second/time.Since(started),
)))
if flags.Seed { if flags.Seed {
if len(client.Torrents()) == 0 { if len(client.Torrents()) == 0 {
log.Print("no torrents to seed") log.Print("no torrents to seed")