From 7dfb0110d433f6c4b988a0bcf9c43aee5582131f Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Thu, 8 Aug 2024 08:20:26 +0300 Subject: [PATCH] Fix Incomplete Save Path cannot be changed for torrents without metadata PR #21152. Closes #21140. --- src/base/bittorrent/torrentimpl.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index b29f8f06e..da5e4690e 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -460,6 +460,8 @@ Path TorrentImpl::savePath() const void TorrentImpl::setSavePath(const Path &path) { Q_ASSERT(!isAutoTMMEnabled()); + if (isAutoTMMEnabled()) [[unlikely]] + return; const Path basePath = m_session->useCategoryPathsInManualMode() ? m_session->categorySavePath(category()) : m_session->savePath(); @@ -487,6 +489,8 @@ Path TorrentImpl::downloadPath() const void TorrentImpl::setDownloadPath(const Path &path) { Q_ASSERT(!isAutoTMMEnabled()); + if (isAutoTMMEnabled()) [[unlikely]] + return; const Path basePath = m_session->useCategoryPathsInManualMode() ? m_session->categoryDownloadPath(category()) : m_session->downloadPath(); @@ -1958,8 +1962,17 @@ void TorrentImpl::moveStorage(const Path &newPath, const MoveStorageContext cont { if (!hasMetadata()) { - m_savePath = newPath; - m_session->handleTorrentSavePathChanged(this); + if (context == MoveStorageContext::ChangeSavePath) + { + m_savePath = newPath; + m_session->handleTorrentSavePathChanged(this); + } + else if (context == MoveStorageContext::ChangeDownloadPath) + { + m_downloadPath = newPath; + m_session->handleTorrentSavePathChanged(this); + } + return; }