From ca9e5e853149d654d17181a3b656b39abd368265 Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Thu, 27 Jan 2022 07:40:17 +0300 Subject: [PATCH] Change torrent moving state when it is cancelled PR #16267. --- src/base/bittorrent/session.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 366a62d0f..916e4571c 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -4033,7 +4033,7 @@ bool Session::addMoveTorrentStorageJob(TorrentImpl *torrent, const QString &newP if (m_moveStorageQueue.size() > 1) { - const auto iter = std::find_if(m_moveStorageQueue.begin() + 1, m_moveStorageQueue.end() + auto iter = std::find_if(m_moveStorageQueue.begin() + 1, m_moveStorageQueue.end() , [&torrentHandle](const MoveStorageJob &job) { return job.torrentHandle == torrentHandle; @@ -4042,8 +4042,16 @@ bool Session::addMoveTorrentStorageJob(TorrentImpl *torrent, const QString &newP if (iter != m_moveStorageQueue.end()) { // remove existing inactive job - m_moveStorageQueue.erase(iter); LogMsg(tr("Cancelled moving \"%1\" from \"%2\" to \"%3\".").arg(torrent->name(), currentLocation, iter->path)); + iter = m_moveStorageQueue.erase(iter); + + iter = std::find_if(iter, m_moveStorageQueue.end(), [&torrentHandle](const MoveStorageJob &job) + { + return job.torrentHandle == torrentHandle; + }); + + const bool torrentHasOutstandingJob = (iter != m_moveStorageQueue.end()); + torrent->handleMoveStorageJobFinished(torrentHasOutstandingJob); } }