Don't use output parameters for error handling

This commit is contained in:
Vladimir Golovnev (Glassez) 2021-10-06 21:45:37 +03:00
commit 41fc0fd084
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
12 changed files with 116 additions and 165 deletions

View file

@ -1698,7 +1698,7 @@ void Session::handleDownloadFinished(const Net::DownloadResult &result)
{
case Net::DownloadStatus::Success:
emit downloadFromUrlFinished(result.url);
addTorrent(TorrentInfo::load(result.data), m_downloadedTorrents.take(result.url));
addTorrent(TorrentInfo::load(result.data).value_or(TorrentInfo()), m_downloadedTorrents.take(result.url));
break;
case Net::DownloadStatus::RedirectedToMagnet:
emit downloadFromUrlFinished(result.url);
@ -2028,7 +2028,7 @@ bool Session::addTorrent(const QString &source, const AddTorrentParams &params)
return addTorrent(magnetUri, params);
TorrentFileGuard guard {source};
if (addTorrent(TorrentInfo::loadFromFile(source), params))
if (addTorrent(TorrentInfo::loadFromFile(source).value_or(TorrentInfo()), params))
{
guard.markAsAddedToSession();
return true;
@ -3938,8 +3938,7 @@ void Session::handleTorrentFinished(TorrentImpl *const torrent)
qDebug("Found possible recursive torrent download.");
const QString torrentFullpath = torrent->savePath(true) + '/' + torrentRelpath;
qDebug("Full subtorrent path is %s", qUtf8Printable(torrentFullpath));
TorrentInfo torrentInfo = TorrentInfo::loadFromFile(torrentFullpath);
if (torrentInfo.isValid())
if (TorrentInfo::loadFromFile(torrentFullpath))
{
qDebug("emitting recursiveTorrentDownloadPossible()");
emit recursiveTorrentDownloadPossible(torrent);
@ -4167,7 +4166,7 @@ void Session::recursiveTorrentDownload(const TorrentID &id)
AddTorrentParams params;
// Passing the save path along to the sub torrent file
params.savePath = torrent->savePath();
addTorrent(TorrentInfo::loadFromFile(torrentFullpath), params);
addTorrent(TorrentInfo::loadFromFile(torrentFullpath).value_or(TorrentInfo()), params);
}
}
}