Fix division by zero error in get_ratio

This commit is contained in:
Andrew Resch 2008-12-09 08:22:20 +00:00
parent 26c607ff66
commit c1f977a2d1
1 changed files with 4 additions and 1 deletions

View File

@ -420,8 +420,11 @@ class Torrent:
downloaded = status.all_time_download
# We use 'total_done' if the downloaded value is 0
if downloaded == 0:
if downloaded == 0 and status.total_done > 0:
downloaded = status.total_done
else:
# Return -1.0 to signify infinity
return -1.0
return float(status.all_time_upload) / float(downloaded)