diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 1e26ca1ce..3a681664d 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -301,7 +301,7 @@ namespace { const BitTorrent::TorrentInfo::PieceRange idx = info.filePieces(index); - QJsonObject fileDict = + const QJsonObject fileDict = { {KEY_FILE_INDEX, index}, {KEY_FILE_PROGRESS, fp[index]}, @@ -412,7 +412,7 @@ void TorrentsController::infoAction() QVariantMap serializedTorrent = serialize(*torrent); - if (includeFiles) + if (includeFiles && torrent->hasMetadata()) serializedTorrent.insert(KEY_PROP_FILES, getFiles(torrent)); if (includeTrackers) serializedTorrent.insert(KEY_PROP_TRACKERS, getTrackers(torrent)); @@ -765,6 +765,9 @@ void TorrentsController::filesAction() }); } + if (!torrent->hasMetadata()) + return setResult(QJsonArray {}); + QJsonArray fileList = getFiles(torrent, fileIndexes); if (!fileList.isEmpty()) {