From 1c654d8f473cc5fb789a9c1b3a3a5a3a1ec3965b Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Sun, 25 Jun 2023 12:45:58 +0300 Subject: [PATCH] Immediately update torrent status on moving files PR #19220. --- src/base/bittorrent/sessionimpl.cpp | 5 +++++ src/base/bittorrent/sessionimpl.h | 1 + src/base/bittorrent/torrentimpl.cpp | 11 +++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index b9274ee5b..043ae3c4a 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -4963,6 +4963,11 @@ void SessionImpl::handleTorrentInfoHashChanged(TorrentImpl *torrent, const InfoH } } +void SessionImpl::handleTorrentStorageMovingStateChanged(TorrentImpl *torrent) +{ + emit torrentsUpdated({torrent}); +} + bool SessionImpl::addMoveTorrentStorageJob(TorrentImpl *torrent, const Path &newPath, const MoveStorageMode mode, const MoveStorageContext context) { Q_ASSERT(torrent); diff --git a/src/base/bittorrent/sessionimpl.h b/src/base/bittorrent/sessionimpl.h index cedecb15a..2df338bcd 100644 --- a/src/base/bittorrent/sessionimpl.h +++ b/src/base/bittorrent/sessionimpl.h @@ -451,6 +451,7 @@ namespace BitTorrent void handleTorrentUrlSeedsRemoved(TorrentImpl *torrent, const QVector &urlSeeds); void handleTorrentResumeDataReady(TorrentImpl *torrent, const LoadTorrentParams &data); void handleTorrentInfoHashChanged(TorrentImpl *torrent, const InfoHash &prevInfoHash); + void handleTorrentStorageMovingStateChanged(TorrentImpl *torrent); bool addMoveTorrentStorageJob(TorrentImpl *torrent, const Path &newPath, MoveStorageMode mode, MoveStorageContext context); diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 8349986b9..de649548f 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -1779,8 +1779,12 @@ void TorrentImpl::moveStorage(const Path &newPath, const MoveStorageContext cont ? MoveStorageMode::Overwrite : MoveStorageMode::KeepExistingFiles; if (m_session->addMoveTorrentStorageJob(this, newPath, mode, context)) { - m_storageIsMoving = true; - updateState(); + if (!m_storageIsMoving) + { + m_storageIsMoving = true; + updateState(); + m_session->handleTorrentStorageMovingStateChanged(this); + } } } @@ -1813,6 +1817,9 @@ void TorrentImpl::handleMoveStorageJobFinished(const Path &path, const MoveStora if (!m_storageIsMoving) { + updateState(); + m_session->handleTorrentStorageMovingStateChanged(this); + if (m_hasMissingFiles) { // it can be moved to the proper location