Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions WebAPI_Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 2.16.0

* [#24388](https://github.com/qbittorrent/qBittorrent/pull/24388)
* `torrents/trackers` endpoint now includes `num_fails` field for tracker entries, reporting the number of consecutive failed announce attempts
Comment on lines +5 to +6
* [#23989](https://github.com/qbittorrent/qBittorrent/pull/23989)
* `sync/torrentPeers` endpoint now includes calculated `contribution` to a peer's progress
* [#24346](https://github.com/qbittorrent/qBittorrent/pull/24346)
Expand Down
8 changes: 8 additions & 0 deletions src/base/bittorrent/torrentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ namespace
trackerEndpointStatus.numSeeds = ltAnnounceInfo.scrape_complete;
trackerEndpointStatus.numLeeches = ltAnnounceInfo.scrape_incomplete;
trackerEndpointStatus.numDownloaded = ltAnnounceInfo.scrape_downloaded;
trackerEndpointStatus.numFails = ltAnnounceInfo.fails;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numFails is always set from ltAnnounceInfo.fails, which is typically 0 before the tracker has ever been contacted. This makes the new Retries column show 0 instead of the intended “N/A” for never-contacted trackers/endpoints (as described in the PR). Consider translating the “not contacted yet” case to -1 at the source.

Does it look bad if Retries column shows 0 for never-contacted trackers/endpoints? IMO, there is nothing contradictory about this.

trackerEndpointStatus.nextAnnounceTime = ltAnnounceInfo.next_announce;
trackerEndpointStatus.minAnnounceTime = ltAnnounceInfo.min_announce;

Expand Down Expand Up @@ -249,6 +250,7 @@ namespace
trackerEntryStatus.numSeeds = -1;
trackerEntryStatus.numLeeches = -1;
trackerEntryStatus.numDownloaded = -1;
trackerEntryStatus.numFails = -1;
trackerEntryStatus.nextAnnounceTime = {};
trackerEntryStatus.minAnnounceTime = {};
trackerEntryStatus.message.clear();
Expand All @@ -259,6 +261,12 @@ namespace
trackerEntryStatus.numSeeds = std::max(trackerEntryStatus.numSeeds, endpointStatus.numSeeds);
trackerEntryStatus.numLeeches = std::max(trackerEntryStatus.numLeeches, endpointStatus.numLeeches);
trackerEntryStatus.numDownloaded = std::max(trackerEntryStatus.numDownloaded, endpointStatus.numDownloaded);
if (endpointStatus.numFails >= 0)
{
trackerEntryStatus.numFails = (trackerEntryStatus.numFails < 0)
? endpointStatus.numFails
: std::min(trackerEntryStatus.numFails, endpointStatus.numFails);
}
Comment on lines +264 to +269

if (endpointStatus.state == trackerEntryStatus.state)
{
Expand Down
1 change: 1 addition & 0 deletions src/base/bittorrent/trackerentrystatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void BitTorrent::TrackerEntryStatus::clear()
numSeeds = -1;
numLeeches = -1;
numDownloaded = -1;
numFails = -1;
nextAnnounceTime = {};
minAnnounceTime = {};
endpoints.clear();
Expand Down
2 changes: 2 additions & 0 deletions src/base/bittorrent/trackerentrystatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace BitTorrent
int numSeeds = -1;
int numLeeches = -1;
int numDownloaded = -1;
int numFails = -1;

AnnounceTimePoint nextAnnounceTime {};
AnnounceTimePoint minAnnounceTime {};
Expand All @@ -77,6 +78,7 @@ namespace BitTorrent
int numSeeds = -1;
int numLeeches = -1;
int numDownloaded = -1;
int numFails = -1;

AnnounceTimePoint nextAnnounceTime {};
AnnounceTimePoint minAnnounceTime {};
Expand Down
11 changes: 11 additions & 0 deletions src/gui/trackerlist/trackerlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ struct TrackerListModel::Item final
int numSeeds = -1;
int numLeeches = -1;
int numDownloaded = -1;
int numFails = -1;

BitTorrent::AnnounceTimePoint nextAnnounceTime;
BitTorrent::AnnounceTimePoint minAnnounceTime;
Expand Down Expand Up @@ -190,6 +191,7 @@ void TrackerListModel::Item::fillFrom(const BitTorrent::TrackerEntryStatus &trac
numSeeds = trackerEntryStatus.numSeeds;
numLeeches = trackerEntryStatus.numLeeches;
numDownloaded = trackerEntryStatus.numDownloaded;
numFails = trackerEntryStatus.numFails;
nextAnnounceTime = trackerEntryStatus.nextAnnounceTime;
minAnnounceTime = trackerEntryStatus.minAnnounceTime;
secsToNextAnnounce = 0;
Expand All @@ -210,6 +212,7 @@ void TrackerListModel::Item::fillFrom(const BitTorrent::TrackerEndpointStatus &e
numSeeds = endpointStatus.numSeeds;
numLeeches = endpointStatus.numLeeches;
numDownloaded = endpointStatus.numDownloaded;
numFails = endpointStatus.numFails;
nextAnnounceTime = endpointStatus.nextAnnounceTime;
minAnnounceTime = endpointStatus.minAnnounceTime;
secsToNextAnnounce = 0;
Expand Down Expand Up @@ -515,6 +518,8 @@ QVariant TrackerListModel::headerData(const int section, const Qt::Orientation o
return tr("Leeches");
case COL_TIMES_DOWNLOADED:
return tr("Times Downloaded");
case COL_RETRIES:
return tr("Retries");
case COL_MSG:
return tr("Message");
case COL_NEXT_ANNOUNCE:
Expand All @@ -533,6 +538,7 @@ QVariant TrackerListModel::headerData(const int section, const Qt::Orientation o
case COL_SEEDS:
case COL_LEECHES:
case COL_TIMES_DOWNLOADED:
case COL_RETRIES:
case COL_NEXT_ANNOUNCE:
case COL_MIN_ANNOUNCE:
return QVariant {Qt::AlignRight | Qt::AlignVCenter};
Expand Down Expand Up @@ -579,6 +585,7 @@ QVariant TrackerListModel::data(const QModelIndex &index, const int role) const
case COL_SEEDS:
case COL_LEECHES:
case COL_TIMES_DOWNLOADED:
case COL_RETRIES:
case COL_NEXT_ANNOUNCE:
case COL_MIN_ANNOUNCE:
return QVariant {Qt::AlignRight | Qt::AlignVCenter};
Expand Down Expand Up @@ -620,6 +627,8 @@ QVariant TrackerListModel::data(const QModelIndex &index, const int role) const
return prettyCount(itemPtr->numLeeches);
case COL_TIMES_DOWNLOADED:
return prettyCount(itemPtr->numDownloaded);
case COL_RETRIES:
return prettyCount(itemPtr->numFails);
case COL_MSG:
return itemPtr->message;
case COL_NEXT_ANNOUNCE:
Expand Down Expand Up @@ -649,6 +658,8 @@ QVariant TrackerListModel::data(const QModelIndex &index, const int role) const
return itemPtr->numLeeches;
case COL_TIMES_DOWNLOADED:
return itemPtr->numDownloaded;
case COL_RETRIES:
return itemPtr->numFails;
case COL_MSG:
return itemPtr->message;
case COL_NEXT_ANNOUNCE:
Expand Down
1 change: 1 addition & 0 deletions src/gui/trackerlist/trackerlistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TrackerListModel final : public QAbstractItemModel
COL_SEEDS,
COL_LEECHES,
COL_TIMES_DOWNLOADED,
COL_RETRIES,
COL_MSG,
Comment on lines 64 to 66
COL_NEXT_ANNOUNCE,
COL_MIN_ANNOUNCE,
Expand Down
3 changes: 3 additions & 0 deletions src/webui/api/torrentscontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const QString KEY_TRACKER_PEERS_COUNT = u"num_peers"_s;
const QString KEY_TRACKER_SEEDS_COUNT = u"num_seeds"_s;
const QString KEY_TRACKER_LEECHES_COUNT = u"num_leeches"_s;
const QString KEY_TRACKER_DOWNLOADED_COUNT = u"num_downloaded"_s;
const QString KEY_TRACKER_FAIL_COUNT = u"num_fails"_s;
Comment thread
LWWZH marked this conversation as resolved.
const QString KEY_TRACKER_NEXT_ANNOUNCE = u"next_announce"_s;
const QString KEY_TRACKER_MIN_ANNOUNCE = u"min_announce"_s;
const QString KEY_TRACKER_ENDPOINTS = u"endpoints"_s;
Expand Down Expand Up @@ -306,6 +307,7 @@ namespace
{KEY_TRACKER_SEEDS_COUNT, endpoint.numSeeds},
{KEY_TRACKER_LEECHES_COUNT, endpoint.numLeeches},
{KEY_TRACKER_DOWNLOADED_COUNT, endpoint.numDownloaded},
{KEY_TRACKER_FAIL_COUNT, endpoint.numFails},
{KEY_TRACKER_NEXT_ANNOUNCE, toSecondsSinceEpoch(endpoint.nextAnnounceTime)},
{KEY_TRACKER_MIN_ANNOUNCE, toSecondsSinceEpoch(endpoint.minAnnounceTime)}
};
Expand All @@ -322,6 +324,7 @@ namespace
{KEY_TRACKER_SEEDS_COUNT, tracker.numSeeds},
{KEY_TRACKER_LEECHES_COUNT, tracker.numLeeches},
{KEY_TRACKER_DOWNLOADED_COUNT, tracker.numDownloaded},
{KEY_TRACKER_FAIL_COUNT, tracker.numFails},
{KEY_TRACKER_NEXT_ANNOUNCE, toSecondsSinceEpoch(tracker.nextAnnounceTime)},
{KEY_TRACKER_MIN_ANNOUNCE, toSecondsSinceEpoch(tracker.minAnnounceTime)},
{KEY_TRACKER_ENDPOINTS, endpointsList}
Expand Down
4 changes: 4 additions & 0 deletions src/webui/www/private/scripts/dynamicTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,7 @@ window.qBittorrent.DynamicTable ??= (() => {
this.newColumn("seeds", "", "QBT_TR(Seeds)QBT_TR[CONTEXT=TrackerListWidget]", 75, true);
this.newColumn("leeches", "", "QBT_TR(Leeches)QBT_TR[CONTEXT=TrackerListWidget]", 75, true);
this.newColumn("downloaded", "", "QBT_TR(Times Downloaded)QBT_TR[CONTEXT=TrackerListWidget]", 100, true);
this.newColumn("fails", "", "QBT_TR(Retries)QBT_TR[CONTEXT=TrackerListWidget]", 50, true);
this.newColumn("message", "", "QBT_TR(Message)QBT_TR[CONTEXT=TrackerListWidget]", 250, true);
this.newColumn("nextAnnounce", "", "QBT_TR(Next Announce)QBT_TR[CONTEXT=TrackerListWidget]", 150, true);
this.newColumn("minAnnounce", "", "QBT_TR(Min Announce)QBT_TR[CONTEXT=TrackerListWidget]", 150, true);
Expand Down Expand Up @@ -2275,6 +2276,9 @@ window.qBittorrent.DynamicTable ??= (() => {
this.columns["seeds"].compareRows = sortMixed;
this.columns["leeches"].compareRows = sortMixed;
this.columns["downloaded"].compareRows = sortMixed;
this.columns["fails"].compareRows = sortMixed;
this.columns["nextAnnounce"].compareRows = sortNumbers;
this.columns["minAnnounce"].compareRows = sortNumbers;

this.columns["status"].updateTd = function(td, row) {
let statusClass = "trackerUnknown";
Expand Down
2 changes: 2 additions & 0 deletions src/webui/www/private/scripts/prop-trackers.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ window.qBittorrent.PropTrackers ??= (() => {
seeds: (tracker.num_seeds >= 0) ? tracker.num_seeds : notApplicable,
leeches: (tracker.num_leeches >= 0) ? tracker.num_leeches : notApplicable,
downloaded: (tracker.num_downloaded >= 0) ? tracker.num_downloaded : notApplicable,
fails: (tracker.num_fails >= 0) ? tracker.num_fails : notApplicable,
message: tracker.msg,
nextAnnounce: tracker.next_announce,
minAnnounce: tracker.min_announce,
Expand All @@ -134,6 +135,7 @@ window.qBittorrent.PropTrackers ??= (() => {
seeds: (endpoint.num_seeds >= 0) ? endpoint.num_seeds : notApplicable,
leeches: (endpoint.num_leeches >= 0) ? endpoint.num_leeches : notApplicable,
downloaded: (endpoint.num_downloaded >= 0) ? endpoint.num_downloaded : notApplicable,
fails: (endpoint.num_fails >= 0) ? endpoint.num_fails : notApplicable,
message: endpoint.msg,
nextAnnounce: endpoint.next_announce,
minAnnounce: endpoint.min_announce,
Expand Down
Loading