From 422b483d783166b6255ea8593ffabb20e1946b99 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 16 Oct 2011 09:41:59 +0300 Subject: [PATCH] Fix ratio calculation for purely seeded torrents --- src/qtlibtorrent/qbtsession.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 738883f1f..532ec1223 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1587,14 +1587,20 @@ qreal QBtSession::getRealRatio(const QString &hash) const{ if(!h.is_valid()) { return 0.; } - const libtorrent::size_type all_time_download = h.all_time_download(); - const libtorrent::size_type all_time_upload = h.all_time_upload(); + + libtorrent::size_type all_time_upload = h.all_time_upload(); + libtorrent::size_type all_time_download = h.all_time_download(); + if (all_time_download == 0 && h.is_seed()) { + // Purely seeded torrent + all_time_download = h.total_done(); + } if(all_time_download == 0) { if(all_time_upload == 0) return 0; return MAX_RATIO+1; } + qreal ratio = all_time_upload / (float) all_time_download; Q_ASSERT(ratio >= 0.); if(ratio > MAX_RATIO)