From 4497ca4a0e6d04058b66e111d529f1c08c99b4a0 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 944322d90..6680ff95a 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -4637,6 +4637,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) { Q_ASSERT(torrent); diff --git a/src/base/bittorrent/sessionimpl.h b/src/base/bittorrent/sessionimpl.h index 45b4bf2d8..9dfb6ff02 100644 --- a/src/base/bittorrent/sessionimpl.h +++ b/src/base/bittorrent/sessionimpl.h @@ -422,6 +422,7 @@ namespace BitTorrent void handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector &urlSeeds); void handleTorrentResumeDataReady(TorrentImpl *const torrent, const LoadTorrentParams &data); void handleTorrentInfoHashChanged(TorrentImpl *torrent, const InfoHash &prevInfoHash); + void handleTorrentStorageMovingStateChanged(TorrentImpl *torrent); bool addMoveTorrentStorageJob(TorrentImpl *torrent, const Path &newPath, MoveStorageMode mode); diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 01e7f528d..423aa26e5 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -1745,8 +1745,12 @@ void TorrentImpl::moveStorage(const Path &newPath, const MoveStorageMode mode) if (m_session->addMoveTorrentStorageJob(this, newPath, mode)) { - m_storageIsMoving = true; - updateState(); + if (!m_storageIsMoving) + { + m_storageIsMoving = true; + updateState(); + m_session->handleTorrentStorageMovingStateChanged(this); + } } } @@ -1778,6 +1782,9 @@ void TorrentImpl::handleMoveStorageJobFinished(const Path &path, const bool hasO if (!m_storageIsMoving) { + updateState(); + m_session->handleTorrentStorageMovingStateChanged(this); + if (m_hasMissingFiles) { // it can be moved to the proper location