From 44223592b08d881032bc8fcd60dffcceeca44d66 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 9 Dec 2008 02:55:20 +0000 Subject: [PATCH] Fix #646 when calculating share ratio use the 'total_done' value if 'all_time_download' is 0 --- deluge/core/torrent.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index bd84efe38..a77a54a13 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -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"""