mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-27 08:19:30 +08:00
Don't overwrite tracker message
Use one of the tracker endpoint messages.
This commit is contained in:
parent
a4ce5d1687
commit
62a6c725d6
@ -86,7 +86,6 @@ namespace BitTorrent
|
||||
|
||||
struct TrackerInfo
|
||||
{
|
||||
QString lastMessage;
|
||||
int numPeers = 0;
|
||||
};
|
||||
|
||||
|
@ -107,6 +107,8 @@ namespace
|
||||
int numUpdating = 0;
|
||||
int numWorking = 0;
|
||||
int numNotWorking = 0;
|
||||
QString firstTrackerMessage;
|
||||
QString firstErrorMessage;
|
||||
#if (LIBTORRENT_VERSION_NUM >= 20000)
|
||||
const int numEndpoints = nativeEntry.endpoints.size() * ((hashes.has_v1() && hashes.has_v2()) ? 2 : 1);
|
||||
trackerEntry.endpoints.reserve(numEndpoints);
|
||||
@ -123,6 +125,7 @@ namespace
|
||||
trackerEndpoint.numSeeds = infoHash.scrape_complete;
|
||||
trackerEndpoint.numLeeches = infoHash.scrape_incomplete;
|
||||
trackerEndpoint.numDownloaded = infoHash.scrape_downloaded;
|
||||
|
||||
if (infoHash.updating)
|
||||
{
|
||||
trackerEndpoint.status = TrackerEntry::Updating;
|
||||
@ -142,11 +145,20 @@ namespace
|
||||
{
|
||||
trackerEndpoint.status = TrackerEntry::NotContacted;
|
||||
}
|
||||
trackerEntry.endpoints.append(trackerEndpoint);
|
||||
|
||||
trackerEntry.numSeeds = std::max(trackerEntry.numSeeds, infoHash.scrape_complete);
|
||||
trackerEntry.numLeeches = std::max(trackerEntry.numLeeches, infoHash.scrape_incomplete);
|
||||
trackerEntry.numDownloaded = std::max(trackerEntry.numDownloaded, infoHash.scrape_downloaded);
|
||||
const QString trackerMessage = QString::fromStdString(infoHash.message);
|
||||
const QString errorMessage = QString::fromLocal8Bit(infoHash.last_error.message().c_str());
|
||||
trackerEndpoint.message = (!trackerMessage.isEmpty() ? trackerMessage : errorMessage);
|
||||
|
||||
trackerEntry.endpoints.append(trackerEndpoint);
|
||||
trackerEntry.numSeeds = std::max(trackerEntry.numSeeds, trackerEndpoint.numSeeds);
|
||||
trackerEntry.numLeeches = std::max(trackerEntry.numLeeches, trackerEndpoint.numLeeches);
|
||||
trackerEntry.numDownloaded = std::max(trackerEntry.numDownloaded, trackerEndpoint.numDownloaded);
|
||||
|
||||
if (firstTrackerMessage.isEmpty())
|
||||
firstTrackerMessage = trackerMessage;
|
||||
if (firstErrorMessage.isEmpty())
|
||||
firstErrorMessage = errorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,6 +171,7 @@ namespace
|
||||
trackerEndpoint.numSeeds = endpoint.scrape_complete;
|
||||
trackerEndpoint.numLeeches = endpoint.scrape_incomplete;
|
||||
trackerEndpoint.numDownloaded = endpoint.scrape_downloaded;
|
||||
|
||||
if (endpoint.updating)
|
||||
{
|
||||
trackerEndpoint.status = TrackerEntry::Updating;
|
||||
@ -178,22 +191,39 @@ namespace
|
||||
{
|
||||
trackerEndpoint.status = TrackerEntry::NotContacted;
|
||||
}
|
||||
trackerEntry.endpoints.append(trackerEndpoint);
|
||||
|
||||
trackerEntry.numSeeds = std::max(trackerEntry.numSeeds, endpoint.scrape_complete);
|
||||
trackerEntry.numLeeches = std::max(trackerEntry.numLeeches, endpoint.scrape_incomplete);
|
||||
trackerEntry.numDownloaded = std::max(trackerEntry.numDownloaded, endpoint.scrape_downloaded);
|
||||
const QString trackerMessage = QString::fromStdString(endpoint.message);
|
||||
const QString errorMessage = QString::fromLocal8Bit(endpoint.last_error.message().c_str());
|
||||
trackerEndpoint.message = (!trackerMessage.isEmpty() ? trackerMessage : errorMessage);
|
||||
|
||||
trackerEntry.endpoints.append(trackerEndpoint);
|
||||
trackerEntry.numSeeds = std::max(trackerEntry.numSeeds, trackerEndpoint.numSeeds);
|
||||
trackerEntry.numLeeches = std::max(trackerEntry.numLeeches, trackerEndpoint.numLeeches);
|
||||
trackerEntry.numDownloaded = std::max(trackerEntry.numDownloaded, trackerEndpoint.numDownloaded);
|
||||
|
||||
if (firstTrackerMessage.isEmpty())
|
||||
firstTrackerMessage = trackerMessage;
|
||||
if (firstErrorMessage.isEmpty())
|
||||
firstErrorMessage = errorMessage;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (numEndpoints > 0)
|
||||
{
|
||||
if (numUpdating > 0)
|
||||
{
|
||||
trackerEntry.status = TrackerEntry::Updating;
|
||||
}
|
||||
else if (numWorking > 0)
|
||||
{
|
||||
trackerEntry.status = TrackerEntry::Working;
|
||||
trackerEntry.message = firstTrackerMessage;
|
||||
}
|
||||
else if (numNotWorking == numEndpoints)
|
||||
{
|
||||
trackerEntry.status = TrackerEntry::NotWorking;
|
||||
trackerEntry.message = (!firstTrackerMessage.isEmpty() ? firstTrackerMessage : firstErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
return trackerEntry;
|
||||
@ -440,11 +470,13 @@ QVector<TrackerEntry> TorrentImpl::trackers() const
|
||||
entries.reserve(nativeTrackers.size());
|
||||
|
||||
for (const lt::announce_entry &tracker : nativeTrackers)
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM >= 20000)
|
||||
entries << fromNativeAnnouncerEntry(tracker, m_nativeHandle.info_hashes());
|
||||
#else
|
||||
entries << fromNativeAnnouncerEntry(tracker);
|
||||
#endif
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
@ -1617,7 +1649,7 @@ void TorrentImpl::handleTrackerReplyAlert(const lt::tracker_reply_alert *p)
|
||||
const QString trackerUrl(p->tracker_url());
|
||||
qDebug("Received a tracker reply from %s (Num_peers = %d)", qUtf8Printable(trackerUrl), p->num_peers);
|
||||
// Connection was successful now. Remove possible old errors
|
||||
m_trackerInfos[trackerUrl] = {{}, p->num_peers};
|
||||
m_trackerInfos[trackerUrl] = {p->num_peers};
|
||||
|
||||
m_session->handleTorrentTrackerReply(this, trackerUrl);
|
||||
}
|
||||
@ -1625,20 +1657,12 @@ void TorrentImpl::handleTrackerReplyAlert(const lt::tracker_reply_alert *p)
|
||||
void TorrentImpl::handleTrackerWarningAlert(const lt::tracker_warning_alert *p)
|
||||
{
|
||||
const QString trackerUrl = p->tracker_url();
|
||||
const QString message = p->warning_message();
|
||||
|
||||
// Connection was successful now but there is a warning message
|
||||
m_trackerInfos[trackerUrl].lastMessage = message; // Store warning message
|
||||
|
||||
m_session->handleTorrentTrackerWarning(this, trackerUrl);
|
||||
}
|
||||
|
||||
void TorrentImpl::handleTrackerErrorAlert(const lt::tracker_error_alert *p)
|
||||
{
|
||||
const QString trackerUrl = p->tracker_url();
|
||||
const QString message = p->error_message();
|
||||
|
||||
m_trackerInfos[trackerUrl].lastMessage = message;
|
||||
|
||||
// Starting with libtorrent 1.2.x each tracker has multiple local endpoints from which
|
||||
// an announce is attempted. Some endpoints might succeed while others might fail.
|
||||
|
@ -52,6 +52,7 @@ namespace BitTorrent
|
||||
int numSeeds = -1;
|
||||
int numLeeches = -1;
|
||||
int numDownloaded = -1;
|
||||
QString message;
|
||||
};
|
||||
|
||||
QString url;
|
||||
@ -64,6 +65,7 @@ namespace BitTorrent
|
||||
int numSeeds = -1;
|
||||
int numLeeches = -1;
|
||||
int numDownloaded = -1;
|
||||
QString message;
|
||||
};
|
||||
|
||||
bool operator==(const TrackerEntry &left, const TrackerEntry &right);
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <QClipboard>
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QHash>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
@ -391,22 +390,19 @@ void TrackerListWidget::loadTrackers()
|
||||
{
|
||||
case BitTorrent::TrackerEntry::Working:
|
||||
item->setText(COL_STATUS, tr("Working"));
|
||||
item->setText(COL_MSG, "");
|
||||
break;
|
||||
case BitTorrent::TrackerEntry::Updating:
|
||||
item->setText(COL_STATUS, tr("Updating..."));
|
||||
item->setText(COL_MSG, "");
|
||||
break;
|
||||
case BitTorrent::TrackerEntry::NotWorking:
|
||||
item->setText(COL_STATUS, tr("Not working"));
|
||||
item->setText(COL_MSG, data.lastMessage.trimmed());
|
||||
break;
|
||||
case BitTorrent::TrackerEntry::NotContacted:
|
||||
item->setText(COL_STATUS, tr("Not contacted yet"));
|
||||
item->setText(COL_MSG, "");
|
||||
break;
|
||||
}
|
||||
|
||||
item->setText(COL_MSG, entry.message);
|
||||
item->setText(COL_PEERS, QString::number(data.numPeers));
|
||||
item->setText(COL_SEEDS, ((entry.numSeeds > -1)
|
||||
? QString::number(entry.numSeeds)
|
||||
|
@ -464,7 +464,7 @@ void TorrentsController::trackersAction()
|
||||
{KEY_TRACKER_TIER, tracker.tier},
|
||||
{KEY_TRACKER_STATUS, static_cast<int>(tracker.status)},
|
||||
{KEY_TRACKER_PEERS_COUNT, data.numPeers},
|
||||
{KEY_TRACKER_MSG, data.lastMessage.trimmed()},
|
||||
{KEY_TRACKER_MSG, tracker.message},
|
||||
{KEY_TRACKER_SEEDS_COUNT, tracker.numSeeds},
|
||||
{KEY_TRACKER_LEECHES_COUNT, tracker.numLeeches},
|
||||
{KEY_TRACKER_DOWNLOADED_COUNT, tracker.numDownloaded}
|
||||
|
Loading…
Reference in New Issue
Block a user