Browse Source

Merge pull request #14537 from glassez/trackerentry

Properly show tracker status for "paused" torrents
adaptive-webui-19844
Vladimir Golovnev 4 years ago committed by GitHub
parent
commit
1568e98d43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      src/base/bittorrent/torrentimpl.cpp

26
src/base/bittorrent/torrentimpl.cpp

@ -118,7 +118,7 @@ namespace @@ -118,7 +118,7 @@ namespace
int numUpdating = 0;
int numWorking = 0;
int numNotContacted = 0;
int numNotWorking = 0;
#if (LIBTORRENT_VERSION_NUM >= 20000)
const int numEndpoints = nativeEntry.endpoints.size() * ((hashes.has_v1() && hashes.has_v2()) ? 2 : 1);
trackerEntry.endpoints.reserve(numEndpoints);
@ -143,6 +143,7 @@ namespace @@ -143,6 +143,7 @@ namespace
else if (infoHash.fails > 0)
{
trackerEndpoint.status = TrackerEntry::NotWorking;
++numNotWorking;
}
else if (nativeEntry.verified)
{
@ -152,7 +153,6 @@ namespace @@ -152,7 +153,6 @@ namespace
else
{
trackerEndpoint.status = TrackerEntry::NotContacted;
++numNotContacted;
}
trackerEntry.endpoints.append(trackerEndpoint);
@ -163,7 +163,8 @@ namespace @@ -163,7 +163,8 @@ namespace
}
}
#else
trackerEntry.endpoints.reserve(nativeEntry.endpoints.size());
const int numEndpoints = nativeEntry.endpoints.size();
trackerEntry.endpoints.reserve(numEndpoints);
for (const lt::announce_endpoint &endpoint : nativeEntry.endpoints)
{
TrackerEntry::EndpointStats trackerEndpoint;
@ -178,6 +179,7 @@ namespace @@ -178,6 +179,7 @@ namespace
else if (endpoint.fails > 0)
{
trackerEndpoint.status = TrackerEntry::NotWorking;
++numNotWorking;
}
else if (nativeEntry.verified)
{
@ -187,7 +189,6 @@ namespace @@ -187,7 +189,6 @@ namespace
else
{
trackerEndpoint.status = TrackerEntry::NotContacted;
++numNotContacted;
}
trackerEntry.endpoints.append(trackerEndpoint);
@ -197,14 +198,15 @@ namespace @@ -197,14 +198,15 @@ namespace
}
#endif
if (numUpdating > 0)
trackerEntry.status = TrackerEntry::Updating;
else if (numWorking > 0)
trackerEntry.status = TrackerEntry::Working;
else if (numNotContacted > 0)
trackerEntry.status = TrackerEntry::NotContacted;
else
trackerEntry.status = TrackerEntry::NotWorking;
if (numEndpoints > 0)
{
if (numUpdating > 0)
trackerEntry.status = TrackerEntry::Updating;
else if (numWorking > 0)
trackerEntry.status = TrackerEntry::Working;
else if (numNotWorking == numEndpoints)
trackerEntry.status = TrackerEntry::NotWorking;
}
return trackerEntry;
}

Loading…
Cancel
Save