mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
fix: check for torrent metadata before getFiles()
This commit is contained in:
parent
f5f69f1865
commit
0a908f93ce
1 changed files with 5 additions and 2 deletions
|
@ -301,7 +301,7 @@ namespace
|
||||||
{
|
{
|
||||||
const BitTorrent::TorrentInfo::PieceRange idx = info.filePieces(index);
|
const BitTorrent::TorrentInfo::PieceRange idx = info.filePieces(index);
|
||||||
|
|
||||||
QJsonObject fileDict =
|
const QJsonObject fileDict =
|
||||||
{
|
{
|
||||||
{KEY_FILE_INDEX, index},
|
{KEY_FILE_INDEX, index},
|
||||||
{KEY_FILE_PROGRESS, fp[index]},
|
{KEY_FILE_PROGRESS, fp[index]},
|
||||||
|
@ -412,7 +412,7 @@ void TorrentsController::infoAction()
|
||||||
|
|
||||||
QVariantMap serializedTorrent = serialize(*torrent);
|
QVariantMap serializedTorrent = serialize(*torrent);
|
||||||
|
|
||||||
if (includeFiles)
|
if (includeFiles && torrent->hasMetadata())
|
||||||
serializedTorrent.insert(KEY_PROP_FILES, getFiles(torrent));
|
serializedTorrent.insert(KEY_PROP_FILES, getFiles(torrent));
|
||||||
if (includeTrackers)
|
if (includeTrackers)
|
||||||
serializedTorrent.insert(KEY_PROP_TRACKERS, getTrackers(torrent));
|
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);
|
QJsonArray fileList = getFiles(torrent, fileIndexes);
|
||||||
if (!fileList.isEmpty())
|
if (!fileList.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue