|
|
@ -4549,32 +4549,19 @@ void SessionImpl::handleTorrentFinished(TorrentImpl *const torrent) |
|
|
|
LogMsg(tr("Torrent download finished. Torrent: \"%1\"").arg(torrent->name())); |
|
|
|
LogMsg(tr("Torrent download finished. Torrent: \"%1\"").arg(torrent->name())); |
|
|
|
emit torrentFinished(torrent); |
|
|
|
emit torrentFinished(torrent); |
|
|
|
|
|
|
|
|
|
|
|
qDebug("Checking if the torrent contains torrent files to download"); |
|
|
|
if (const Path exportPath = finishedTorrentExportDirectory(); !exportPath.isEmpty()) |
|
|
|
// Check if there are torrent files inside
|
|
|
|
exportTorrentFile(torrent, exportPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check whether it contains .torrent files
|
|
|
|
for (const Path &torrentRelpath : asConst(torrent->filePaths())) |
|
|
|
for (const Path &torrentRelpath : asConst(torrent->filePaths())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (torrentRelpath.hasExtension(u".torrent"_qs)) |
|
|
|
if (torrentRelpath.hasExtension(u".torrent"_qs)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug("Found possible recursive torrent download."); |
|
|
|
emit recursiveTorrentDownloadPossible(torrent); |
|
|
|
const Path torrentFullpath = torrent->actualStorageLocation() / torrentRelpath; |
|
|
|
break; |
|
|
|
qDebug("Full subtorrent path is %s", qUtf8Printable(torrentFullpath.toString())); |
|
|
|
|
|
|
|
if (TorrentInfo::loadFromFile(torrentFullpath)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
qDebug("emitting recursiveTorrentDownloadPossible()"); |
|
|
|
|
|
|
|
emit recursiveTorrentDownloadPossible(torrent); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
qDebug("Caught error loading torrent"); |
|
|
|
|
|
|
|
LogMsg(tr("Unable to load torrent. File: \"%1\"").arg(torrentFullpath.toString()), Log::CRITICAL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!finishedTorrentExportDirectory().isEmpty()) |
|
|
|
|
|
|
|
exportTorrentFile(torrent, finishedTorrentExportDirectory()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasUnfinishedTorrents()) |
|
|
|
if (!hasUnfinishedTorrents()) |
|
|
|
emit allTorrentsFinished(); |
|
|
|
emit allTorrentsFinished(); |
|
|
|
} |
|
|
|
} |
|
|
@ -4859,25 +4846,32 @@ void SessionImpl::disableIPFilter() |
|
|
|
|
|
|
|
|
|
|
|
void SessionImpl::recursiveTorrentDownload(const TorrentID &id) |
|
|
|
void SessionImpl::recursiveTorrentDownload(const TorrentID &id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TorrentImpl *const torrent = m_torrents.value(id); |
|
|
|
const TorrentImpl *torrent = m_torrents.value(id); |
|
|
|
if (!torrent) return; |
|
|
|
if (!torrent) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
for (const Path &torrentRelpath : asConst(torrent->filePaths())) |
|
|
|
for (const Path &torrentRelpath : asConst(torrent->filePaths())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (torrentRelpath.hasExtension(u".torrent"_qs)) |
|
|
|
if (torrentRelpath.hasExtension(u".torrent"_qs)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogMsg(tr("Recursive download .torrent file within torrent. Source torrent: \"%1\". File: \"%2\"") |
|
|
|
|
|
|
|
.arg(torrent->name(), torrentRelpath.toString())); |
|
|
|
|
|
|
|
const Path torrentFullpath = torrent->savePath() / torrentRelpath; |
|
|
|
const Path torrentFullpath = torrent->savePath() / torrentRelpath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogMsg(tr("Recursive download .torrent file within torrent. Source torrent: \"%1\". File: \"%2\"") |
|
|
|
|
|
|
|
.arg(torrent->name(), torrentFullpath.toString())); |
|
|
|
|
|
|
|
|
|
|
|
AddTorrentParams params; |
|
|
|
AddTorrentParams params; |
|
|
|
// Passing the save path along to the sub torrent file
|
|
|
|
// Passing the save path along to the sub torrent file
|
|
|
|
params.savePath = torrent->savePath(); |
|
|
|
params.savePath = torrent->savePath(); |
|
|
|
const nonstd::expected<TorrentInfo, QString> loadResult = TorrentInfo::loadFromFile(torrentFullpath); |
|
|
|
const nonstd::expected<TorrentInfo, QString> loadResult = TorrentInfo::loadFromFile(torrentFullpath); |
|
|
|
if (loadResult) |
|
|
|
if (loadResult) |
|
|
|
|
|
|
|
{ |
|
|
|
addTorrent(loadResult.value(), params); |
|
|
|
addTorrent(loadResult.value(), params); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogMsg(tr("Failed to load torrent. Error: \"%1\"").arg(loadResult.error()), Log::WARNING); |
|
|
|
{ |
|
|
|
|
|
|
|
LogMsg(tr("Failed to load .torrent file within torrent. Source torrent: \"%1\". File: \"%2\". Error: \"%3\"") |
|
|
|
|
|
|
|
.arg(torrent->name(), torrentFullpath.toString(), loadResult.error()), Log::WARNING); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|