Browse Source

Properly show tracker status for "paused" torrents

adaptive-webui-19844
Vladimir Golovnev (Glassez) 4 years ago
parent
commit
0c9ecd1d76
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
  1. 26
      src/base/bittorrent/torrentimpl.cpp

26
src/base/bittorrent/torrentimpl.cpp

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

Loading…
Cancel
Save