From 43e9403a4cf22cc78e8157db5fbe35afd15cfacb Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Fri, 29 Sep 2023 07:33:19 +0300 Subject: [PATCH] Filter out duplicate trackers when replacing PR #19656. --- src/base/bittorrent/torrentimpl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 5f59f996f..57ccb5c41 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -657,6 +657,9 @@ void TorrentImpl::removeTrackers(const QStringList &trackers) void TorrentImpl::replaceTrackers(QVector trackers) { trackers.removeIf([](const TrackerEntry &entry) { return entry.url.isEmpty(); }); + // Filter out duplicate trackers + const auto uniqueTrackers = QSet(trackers.cbegin(), trackers.cend()); + trackers = QVector(uniqueTrackers.cbegin(), uniqueTrackers.cend()); std::sort(trackers.begin(), trackers.end() , [](const TrackerEntry &lhs, const TrackerEntry &rhs) { return lhs.tier < rhs.tier; });