Skip to content

Commit e721701

Browse files
committed
handle non-torrent RSS link
1 parent 52d3a96 commit e721701

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/webui/api/torrentscontroller.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,6 +2231,11 @@ void TorrentsController::fetchMetadataAction()
22312231
// http(s) url
22322232
else if (Net::DownloadManager::hasSupportedScheme(source))
22332233
{
2234+
if (m_invalidTorrentSource.contains(source))
2235+
{
2236+
throw APIError(APIErrorType::BadData, tr("'%1' is not a valid torrent file.").arg(source));
2237+
}
2238+
22342239
if (!m_requestedTorrentSource.contains(source))
22352240
{
22362241
if (!downloaderParam.isEmpty())
@@ -2444,10 +2449,12 @@ void TorrentsController::cacheTorrentFile(const QString &source, const QByteArra
24442449
const BitTorrent::InfoHash infoHash = torrentDescr.infoHash();
24452450
m_torrentSourceCache.insert(source, infoHash);
24462451
m_torrentMetadataCache.insert(infoHash.toTorrentID(), torrentDescr);
2452+
m_invalidTorrentSource.remove(source);
24472453
}
24482454
else
24492455
{
24502456
LogMsg(tr("Parse torrent failed. URL: \"%1\". Error: \"%2\".").arg(source, loadResult.error()), Log::WARNING);
2457+
m_invalidTorrentSource.insert(source);
24512458
m_torrentSourceCache.remove(source);
24522459
}
24532460
}

src/webui/api/torrentscontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,5 @@ private slots:
130130
QHash<QString, BitTorrent::InfoHash> m_torrentSourceCache;
131131
QHash<BitTorrent::TorrentID, BitTorrent::TorrentDescriptor> m_torrentMetadataCache;
132132
QSet<QString> m_requestedTorrentSource;
133+
QSet<QString> m_invalidTorrentSource;
133134
};

src/webui/www/private/scripts/addtorrent.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ window.qBittorrent.AddTorrent ??= (() => {
278278
.then(async (response) => {
279279
if (!response.ok) {
280280
metadataFailed();
281+
if (response.status === 415) {
282+
alert(await response.text());
283+
}
281284
return;
282285
}
283286

0 commit comments

Comments
 (0)