mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 16:37:21 -06:00
Merge pull request #17725 from Chocobo1/downloadsDone
Clean up 'recursive download' related code
This commit is contained in:
@@ -4549,32 +4549,19 @@ void SessionImpl::handleTorrentFinished(TorrentImpl *const torrent)
|
||||
LogMsg(tr("Torrent download finished. Torrent: \"%1\"").arg(torrent->name()));
|
||||
emit torrentFinished(torrent);
|
||||
|
||||
qDebug("Checking if the torrent contains torrent files to download");
|
||||
// Check if there are torrent files inside
|
||||
if (const Path exportPath = finishedTorrentExportDirectory(); !exportPath.isEmpty())
|
||||
exportTorrentFile(torrent, exportPath);
|
||||
|
||||
// Check whether it contains .torrent files
|
||||
for (const Path &torrentRelpath : asConst(torrent->filePaths()))
|
||||
{
|
||||
if (torrentRelpath.hasExtension(u".torrent"_qs))
|
||||
{
|
||||
qDebug("Found possible recursive torrent download.");
|
||||
const Path torrentFullpath = torrent->actualStorageLocation() / torrentRelpath;
|
||||
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);
|
||||
}
|
||||
emit recursiveTorrentDownloadPossible(torrent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!finishedTorrentExportDirectory().isEmpty())
|
||||
exportTorrentFile(torrent, finishedTorrentExportDirectory());
|
||||
|
||||
if (!hasUnfinishedTorrents())
|
||||
emit allTorrentsFinished();
|
||||
}
|
||||
@@ -4859,25 +4846,32 @@ void SessionImpl::disableIPFilter()
|
||||
|
||||
void SessionImpl::recursiveTorrentDownload(const TorrentID &id)
|
||||
{
|
||||
TorrentImpl *const torrent = m_torrents.value(id);
|
||||
if (!torrent) return;
|
||||
const TorrentImpl *torrent = m_torrents.value(id);
|
||||
if (!torrent)
|
||||
return;
|
||||
|
||||
for (const Path &torrentRelpath : asConst(torrent->filePaths()))
|
||||
{
|
||||
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;
|
||||
|
||||
LogMsg(tr("Recursive download .torrent file within torrent. Source torrent: \"%1\". File: \"%2\"")
|
||||
.arg(torrent->name(), torrentFullpath.toString()));
|
||||
|
||||
AddTorrentParams params;
|
||||
// Passing the save path along to the sub torrent file
|
||||
params.savePath = torrent->savePath();
|
||||
const nonstd::expected<TorrentInfo, QString> loadResult = TorrentInfo::loadFromFile(torrentFullpath);
|
||||
if (loadResult)
|
||||
{
|
||||
addTorrent(loadResult.value(), params);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1772,10 +1772,10 @@ void TorrentImpl::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p)
|
||||
void TorrentImpl::handleTorrentFinishedAlert(const lt::torrent_finished_alert *p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
qDebug("Got a torrent finished alert for \"%s\"", qUtf8Printable(name()));
|
||||
qDebug("Torrent has seed status: %s", m_hasSeedStatus ? "yes" : "no");
|
||||
|
||||
m_hasMissingFiles = false;
|
||||
if (m_hasSeedStatus) return;
|
||||
if (m_hasSeedStatus)
|
||||
return;
|
||||
|
||||
m_statusUpdatedTriggers.enqueue([this]()
|
||||
{
|
||||
|
||||
@@ -996,14 +996,14 @@ void Preferences::resolvePeerHostNames(const bool resolve)
|
||||
setValue(u"Preferences/Connection/ResolvePeerHostNames"_qs, resolve);
|
||||
}
|
||||
|
||||
bool Preferences::recursiveDownloadDisabled() const
|
||||
bool Preferences::isRecursiveDownloadEnabled() const
|
||||
{
|
||||
return value(u"Preferences/Advanced/DisableRecursiveDownload"_qs, false);
|
||||
return !value(u"Preferences/Advanced/DisableRecursiveDownload"_qs, false);
|
||||
}
|
||||
|
||||
void Preferences::disableRecursiveDownload(const bool disable)
|
||||
void Preferences::setRecursiveDownloadEnabled(const bool enable)
|
||||
{
|
||||
setValue(u"Preferences/Advanced/DisableRecursiveDownload"_qs, disable);
|
||||
setValue(u"Preferences/Advanced/DisableRecursiveDownload"_qs, !enable);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
@@ -281,8 +281,8 @@ public:
|
||||
void resolvePeerCountries(bool resolve);
|
||||
bool resolvePeerHostNames() const;
|
||||
void resolvePeerHostNames(bool resolve);
|
||||
bool recursiveDownloadDisabled() const;
|
||||
void disableRecursiveDownload(bool disable = true);
|
||||
bool isRecursiveDownloadEnabled() const;
|
||||
void setRecursiveDownloadEnabled(bool enable);
|
||||
#ifdef Q_OS_WIN
|
||||
bool neverCheckFileAssoc() const;
|
||||
void setNeverCheckFileAssoc(bool check = true);
|
||||
|
||||
Reference in New Issue
Block a user