diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 3a681664d..4e98fd9d6 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -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 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()) {