mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 16:53:08 -07:00
Correctly handle "torrent finished after move" event
PR #21596. Closes #21576.
This commit is contained in:
parent
966387859a
commit
8e941a06f1
2 changed files with 31 additions and 22 deletions
|
@ -5221,6 +5221,9 @@ void SessionImpl::handleMoveTorrentStorageJobFinished(const Path &newPath)
|
||||||
if (torrent)
|
if (torrent)
|
||||||
{
|
{
|
||||||
torrent->handleMoveStorageJobFinished(newPath, finishedJob.context, torrentHasOutstandingJob);
|
torrent->handleMoveStorageJobFinished(newPath, finishedJob.context, torrentHasOutstandingJob);
|
||||||
|
// The torrent may become "finished" at the end of the move if it was moved
|
||||||
|
// from the "incomplete" location after downloading finished.
|
||||||
|
processPendingFinishedTorrents();
|
||||||
}
|
}
|
||||||
else if (!torrentHasOutstandingJob)
|
else if (!torrentHasOutstandingJob)
|
||||||
{
|
{
|
||||||
|
@ -5232,6 +5235,32 @@ void SessionImpl::handleMoveTorrentStorageJobFinished(const Path &newPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionImpl::processPendingFinishedTorrents()
|
||||||
|
{
|
||||||
|
if (m_pendingFinishedTorrents.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (TorrentImpl *torrent : asConst(m_pendingFinishedTorrents))
|
||||||
|
{
|
||||||
|
LogMsg(tr("Torrent download finished. Torrent: \"%1\"").arg(torrent->name()));
|
||||||
|
emit torrentFinished(torrent);
|
||||||
|
|
||||||
|
if (const Path exportPath = finishedTorrentExportDirectory(); !exportPath.isEmpty())
|
||||||
|
exportTorrentFile(torrent, exportPath);
|
||||||
|
|
||||||
|
processTorrentShareLimits(torrent);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pendingFinishedTorrents.clear();
|
||||||
|
|
||||||
|
const bool hasUnfinishedTorrents = std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentImpl *torrent)
|
||||||
|
{
|
||||||
|
return !(torrent->isFinished() || torrent->isStopped() || torrent->isErrored());
|
||||||
|
});
|
||||||
|
if (!hasUnfinishedTorrents)
|
||||||
|
emit allTorrentsFinished();
|
||||||
|
}
|
||||||
|
|
||||||
void SessionImpl::storeCategories() const
|
void SessionImpl::storeCategories() const
|
||||||
{
|
{
|
||||||
QJsonObject jsonObj;
|
QJsonObject jsonObj;
|
||||||
|
@ -6129,28 +6158,7 @@ void SessionImpl::handleStateUpdateAlert(const lt::state_update_alert *alert)
|
||||||
if (!updatedTorrents.isEmpty())
|
if (!updatedTorrents.isEmpty())
|
||||||
emit torrentsUpdated(updatedTorrents);
|
emit torrentsUpdated(updatedTorrents);
|
||||||
|
|
||||||
if (!m_pendingFinishedTorrents.isEmpty())
|
processPendingFinishedTorrents();
|
||||||
{
|
|
||||||
for (TorrentImpl *torrent : m_pendingFinishedTorrents)
|
|
||||||
{
|
|
||||||
LogMsg(tr("Torrent download finished. Torrent: \"%1\"").arg(torrent->name()));
|
|
||||||
emit torrentFinished(torrent);
|
|
||||||
|
|
||||||
if (const Path exportPath = finishedTorrentExportDirectory(); !exportPath.isEmpty())
|
|
||||||
exportTorrentFile(torrent, exportPath);
|
|
||||||
|
|
||||||
processTorrentShareLimits(torrent);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pendingFinishedTorrents.clear();
|
|
||||||
|
|
||||||
const bool hasUnfinishedTorrents = std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentImpl *torrent)
|
|
||||||
{
|
|
||||||
return !(torrent->isFinished() || torrent->isStopped() || torrent->isErrored());
|
|
||||||
});
|
|
||||||
if (!hasUnfinishedTorrents)
|
|
||||||
emit allTorrentsFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_needSaveTorrentsQueue)
|
if (m_needSaveTorrentsQueue)
|
||||||
saveTorrentsQueue();
|
saveTorrentsQueue();
|
||||||
|
|
|
@ -598,6 +598,7 @@ namespace BitTorrent
|
||||||
|
|
||||||
void moveTorrentStorage(const MoveStorageJob &job) const;
|
void moveTorrentStorage(const MoveStorageJob &job) const;
|
||||||
void handleMoveTorrentStorageJobFinished(const Path &newPath);
|
void handleMoveTorrentStorageJobFinished(const Path &newPath);
|
||||||
|
void processPendingFinishedTorrents();
|
||||||
|
|
||||||
void loadCategories();
|
void loadCategories();
|
||||||
void storeCategories() const;
|
void storeCategories() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue