Browse Source

Filter out duplicate trackers when replacing

PR #19656.
adaptive-webui-19844
Vladimir Golovnev 1 year ago committed by GitHub
parent
commit
43e9403a4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/base/bittorrent/torrentimpl.cpp

3
src/base/bittorrent/torrentimpl.cpp

@ -657,6 +657,9 @@ void TorrentImpl::removeTrackers(const QStringList &trackers)
void TorrentImpl::replaceTrackers(QVector<TrackerEntry> trackers) void TorrentImpl::replaceTrackers(QVector<TrackerEntry> trackers)
{ {
trackers.removeIf([](const TrackerEntry &entry) { return entry.url.isEmpty(); }); trackers.removeIf([](const TrackerEntry &entry) { return entry.url.isEmpty(); });
// Filter out duplicate trackers
const auto uniqueTrackers = QSet<TrackerEntry>(trackers.cbegin(), trackers.cend());
trackers = QVector<TrackerEntry>(uniqueTrackers.cbegin(), uniqueTrackers.cend());
std::sort(trackers.begin(), trackers.end() std::sort(trackers.begin(), trackers.end()
, [](const TrackerEntry &lhs, const TrackerEntry &rhs) { return lhs.tier < rhs.tier; }); , [](const TrackerEntry &lhs, const TrackerEntry &rhs) { return lhs.tier < rhs.tier; });

Loading…
Cancel
Save