mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
Fix peer count issue when tracker responds with zero figure
Sometimes tracker may respond with 0 for num_complete and num_incomplete and we should display that instead of deducing the peer count from peer list. We should only fallback to peer list if tracker does not respond with any information. In such cases num_incomplete and num_complete is set to -1 by libtorrent. PR #17432.
This commit is contained in:
parent
36bc77e2e2
commit
2071ec0c96
@ -239,8 +239,6 @@ namespace BitTorrent
|
||||
virtual int totalSeedsCount() const = 0;
|
||||
virtual int totalPeersCount() const = 0;
|
||||
virtual int totalLeechersCount() const = 0;
|
||||
virtual int completeCount() const = 0;
|
||||
virtual int incompleteCount() const = 0;
|
||||
virtual QDateTime lastSeenComplete() const = 0;
|
||||
virtual QDateTime completedTime() const = 0;
|
||||
virtual qlonglong timeSinceUpload() const = 0;
|
||||
|
@ -1153,30 +1153,18 @@ int TorrentImpl::leechsCount() const
|
||||
|
||||
int TorrentImpl::totalSeedsCount() const
|
||||
{
|
||||
return (m_nativeStatus.num_complete > 0) ? m_nativeStatus.num_complete : m_nativeStatus.list_seeds;
|
||||
return (m_nativeStatus.num_complete > -1) ? m_nativeStatus.num_complete : m_nativeStatus.list_seeds;
|
||||
}
|
||||
|
||||
int TorrentImpl::totalPeersCount() const
|
||||
{
|
||||
const int peers = m_nativeStatus.num_complete + m_nativeStatus.num_incomplete;
|
||||
return (peers > 0) ? peers : m_nativeStatus.list_peers;
|
||||
return (peers > -1) ? peers : m_nativeStatus.list_peers;
|
||||
}
|
||||
|
||||
int TorrentImpl::totalLeechersCount() const
|
||||
{
|
||||
return (m_nativeStatus.num_incomplete > 0) ? m_nativeStatus.num_incomplete : (m_nativeStatus.list_peers - m_nativeStatus.list_seeds);
|
||||
}
|
||||
|
||||
int TorrentImpl::completeCount() const
|
||||
{
|
||||
// additional info: https://github.com/qbittorrent/qBittorrent/pull/5300#issuecomment-267783646
|
||||
return m_nativeStatus.num_complete;
|
||||
}
|
||||
|
||||
int TorrentImpl::incompleteCount() const
|
||||
{
|
||||
// additional info: https://github.com/qbittorrent/qBittorrent/pull/5300#issuecomment-267783646
|
||||
return m_nativeStatus.num_incomplete;
|
||||
return (m_nativeStatus.num_incomplete > -1) ? m_nativeStatus.num_incomplete : (m_nativeStatus.list_peers - m_nativeStatus.list_seeds);
|
||||
}
|
||||
|
||||
QDateTime TorrentImpl::lastSeenComplete() const
|
||||
|
@ -171,8 +171,6 @@ namespace BitTorrent
|
||||
int totalSeedsCount() const override;
|
||||
int totalPeersCount() const override;
|
||||
int totalLeechersCount() const override;
|
||||
int completeCount() const override;
|
||||
int incompleteCount() const override;
|
||||
QDateTime lastSeenComplete() const override;
|
||||
QDateTime completedTime() const override;
|
||||
qlonglong timeSinceUpload() const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user