Skip to content

Commit

Permalink
only update download rate when its positive
Browse files Browse the repository at this point in the history
  • Loading branch information
jpillora committed Jan 14, 2016
1 parent 9374175 commit 2d33051
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion engine/torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ func (torrent *Torrent) Update(t torrent.Torrent) {
if !torrent.updatedAt.IsZero() {
dt := float32(now.Sub(torrent.updatedAt))
db := float32(bytes - torrent.Downloaded)
torrent.DownloadRate = db * (float32(time.Second) / dt)
rate := db * (float32(time.Second) / dt)
if rate >= 0 {
torrent.DownloadRate = rate
}
}
torrent.Downloaded = bytes
torrent.updatedAt = now
Expand Down

0 comments on commit 2d33051

Please sign in to comment.