Fix #646 when calculating share ratio use the 'total_done' value if 'all_time_download' is 0

This commit is contained in:
Andrew Resch 2008-12-09 02:55:20 +00:00
parent 56fb8f6225
commit 44223592b0
1 changed files with 5 additions and 4 deletions

View File

@ -418,11 +418,12 @@ class Torrent:
else:
status = self.status
# Return -1.0 if the downloaded bytes is 0, this is to represent infinity
if status.all_time_download == 0:
return -1.0
downloaded = status.all_time_download
# We use 'total_done' if the downloaded value is 0
if downloaded == 0:
downloaded = status.total_done
return float(status.all_time_upload) / float(status.all_time_download)
return float(status.all_time_upload) / float(downloaded)
def get_files(self):
"""Returns a list of files this torrent contains"""