fix: early return for missing metadata

This commit is contained in:
ShanaryS 2025-05-27 11:06:02 -04:00
commit 7b268614e1

View file

@ -744,6 +744,8 @@ void TorrentsController::filesAction()
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
if (!torrent)
throw APIError(APIErrorType::NotFound);
if (!torrent->hasMetadata())
return setResult(QJsonArray{});
QList<int> fileIndexes;
const auto idxIt = params().constFind(u"indexes"_s);
@ -765,9 +767,6 @@ void TorrentsController::filesAction()
});
}
if (!torrent->hasMetadata())
return setResult(QJsonArray {});
QJsonArray fileList = getFiles(torrent, fileIndexes);
if (!fileList.isEmpty())
{