mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
committed by
GitHub
parent
8c0cd09823
commit
7e0cd223fd
@@ -767,8 +767,8 @@ void TorrentsController::editTrackerAction()
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const QUrl origTrackerUrl(origUrl);
|
||||
const QUrl newTrackerUrl(newUrl);
|
||||
const QUrl origTrackerUrl {origUrl};
|
||||
const QUrl newTrackerUrl {newUrl};
|
||||
if (origTrackerUrl == newTrackerUrl)
|
||||
return;
|
||||
if (!newTrackerUrl.isValid())
|
||||
@@ -778,7 +778,7 @@ void TorrentsController::editTrackerAction()
|
||||
bool match = false;
|
||||
for (BitTorrent::TrackerEntry &tracker : trackers)
|
||||
{
|
||||
const QUrl trackerUrl(tracker.url);
|
||||
const QUrl trackerUrl {tracker.url};
|
||||
if (trackerUrl == newTrackerUrl)
|
||||
throw APIError(APIErrorType::Conflict, u"New tracker URL already exists"_qs);
|
||||
if (trackerUrl == origTrackerUrl)
|
||||
@@ -806,20 +806,7 @@ void TorrentsController::removeTrackersAction()
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const QStringList urls = params()[u"urls"_qs].split(u'|');
|
||||
|
||||
const QVector<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
||||
QVector<BitTorrent::TrackerEntry> remainingTrackers;
|
||||
remainingTrackers.reserve(trackers.size());
|
||||
for (const BitTorrent::TrackerEntry &entry : trackers)
|
||||
{
|
||||
if (!urls.contains(entry.url))
|
||||
remainingTrackers.push_back(entry);
|
||||
}
|
||||
|
||||
if (remainingTrackers.size() == trackers.size())
|
||||
throw APIError(APIErrorType::Conflict, u"No trackers were removed"_qs);
|
||||
|
||||
torrent->replaceTrackers(remainingTrackers);
|
||||
torrent->removeTrackers(urls);
|
||||
|
||||
if (!torrent->isPaused())
|
||||
torrent->forceReannounce();
|
||||
|
||||
Reference in New Issue
Block a user