Browse Source

Merge pull request #9817 from Piccirello/torrent-dl-success

Handle downloading .torrent file as success
adaptive-webui-19844
Vladimir Golovnev 6 years ago committed by GitHub
parent
commit
54e4806e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/base/bittorrent/session.cpp

18
src/base/bittorrent/session.cpp

@ -2087,10 +2087,10 @@ TorrentStatusReport Session::torrentStatusReport() const
bool Session::addTorrent(QString source, const AddTorrentParams &params) bool Session::addTorrent(QString source, const AddTorrentParams &params)
{ {
MagnetUri magnetUri(source); MagnetUri magnetUri(source);
if (magnetUri.isValid()) { if (magnetUri.isValid())
return addTorrent_impl(params, magnetUri); return addTorrent_impl(params, magnetUri);
}
else if (Utils::Misc::isUrl(source)) { if (Utils::Misc::isUrl(source)) {
LogMsg(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(source)); LogMsg(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(source));
// Launch downloader // Launch downloader
Net::DownloadHandler *handler = Net::DownloadHandler *handler =
@ -2100,13 +2100,13 @@ bool Session::addTorrent(QString source, const AddTorrentParams &params)
connect(handler, &Net::DownloadHandler::downloadFailed, this, &Session::handleDownloadFailed); connect(handler, &Net::DownloadHandler::downloadFailed, this, &Session::handleDownloadFailed);
connect(handler, &Net::DownloadHandler::redirectedToMagnet, this, &Session::handleRedirectedToMagnet); connect(handler, &Net::DownloadHandler::redirectedToMagnet, this, &Session::handleRedirectedToMagnet);
m_downloadedTorrents[handler->url()] = params; m_downloadedTorrents[handler->url()] = params;
return true;
} }
else {
TorrentFileGuard guard(source); TorrentFileGuard guard(source);
if (addTorrent_impl(params, MagnetUri(), TorrentInfo::loadFromFile(source))) { if (addTorrent_impl(params, MagnetUri(), TorrentInfo::loadFromFile(source))) {
guard.markAsAddedToSession(); guard.markAsAddedToSession();
return true; return true;
}
} }
return false; return false;

Loading…
Cancel
Save