Make TorrentInfo immutable

This commit is contained in:
Vladimir Golovnev (Glassez) 2021-12-09 13:05:49 +03:00
commit 62b50d1475
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
22 changed files with 382 additions and 255 deletions

View file

@ -594,9 +594,12 @@ void TorrentsController::pieceHashesAction()
throw APIError(APIErrorType::NotFound);
QJsonArray pieceHashes;
const QVector<QByteArray> hashes = torrent->info().pieceHashes();
for (const QByteArray &hash : hashes)
pieceHashes.append(QString(hash.toHex()));
if (torrent->hasMetadata())
{
const QVector<QByteArray> hashes = torrent->info().pieceHashes();
for (const QByteArray &hash : hashes)
pieceHashes.append(QString(hash.toHex()));
}
setResult(pieceHashes);
}