From ecd49148d0266c981099cc97f6468b4235a25ef1 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 27 Dec 2016 19:36:08 +0800 Subject: [PATCH 1/2] Fix webUI used the wrong value. Closes #6232. --- src/webui/btjson.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 8f8e2eb23..7fa3a9388 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -707,9 +707,9 @@ QVariantMap toMap(BitTorrent::TorrentHandle *const torrent) ret[KEY_TORRENT_UPSPEED] = torrent->uploadPayloadRate(); ret[KEY_TORRENT_PRIORITY] = torrent->queuePosition(); ret[KEY_TORRENT_SEEDS] = torrent->seedsCount(); - ret[KEY_TORRENT_NUM_COMPLETE] = torrent->completeCount(); + ret[KEY_TORRENT_NUM_COMPLETE] = torrent->totalSeedsCount(); ret[KEY_TORRENT_LEECHS] = torrent->leechsCount(); - ret[KEY_TORRENT_NUM_INCOMPLETE] = torrent->incompleteCount(); + ret[KEY_TORRENT_NUM_INCOMPLETE] = torrent->totalLeechersCount(); const qreal ratio = torrent->realRatio(); ret[KEY_TORRENT_RATIO] = (ratio > BitTorrent::TorrentHandle::MAX_RATIO) ? -1 : ratio; ret[KEY_TORRENT_STATE] = torrent->state().toString(); From 72a6f7ae24b2fac41e9a3552e94e2d7e5da09c66 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 25 May 2016 18:47:28 +0800 Subject: [PATCH 2/2] Use the numbers from tracker scrape response. Closes #5048, #6117. Add comments Thanks to Ian Kent for helping investigate --- src/base/bittorrent/torrenthandle.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index b03bf90af..2d8bc8140 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -915,26 +915,29 @@ int TorrentHandle::leechsCount() const int TorrentHandle::totalSeedsCount() const { - return m_nativeStatus.list_seeds; + return (m_nativeStatus.num_complete > 0) ? m_nativeStatus.num_complete : m_nativeStatus.list_seeds; } int TorrentHandle::totalPeersCount() const { - return m_nativeStatus.list_peers; + int peers = m_nativeStatus.num_complete + m_nativeStatus.num_incomplete; + return (peers > 0) ? peers : m_nativeStatus.list_peers; } int TorrentHandle::totalLeechersCount() const { - return (m_nativeStatus.list_peers - m_nativeStatus.list_seeds); + return (m_nativeStatus.num_incomplete > 0) ? m_nativeStatus.num_incomplete : (m_nativeStatus.list_peers - m_nativeStatus.list_seeds); } int TorrentHandle::completeCount() const { + // additional info: https://github.com/qbittorrent/qBittorrent/pull/5300#issuecomment-267783646 return m_nativeStatus.num_complete; } int TorrentHandle::incompleteCount() const { + // additional info: https://github.com/qbittorrent/qBittorrent/pull/5300#issuecomment-267783646 return m_nativeStatus.num_incomplete; }