From 04c19886656652ae7d12e2fd12708945c7e9dbf2 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Fri, 25 Feb 2022 12:46:22 +0300 Subject: [PATCH] Correctly handle changing of global save path --- src/base/bittorrent/session.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 2a9d76cc9..ad2e62f41 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -2525,18 +2525,27 @@ void Session::setSavePath(const Path &path) if (newPath == m_savePath) return; - m_savePath = newPath; - if (isDisableAutoTMMWhenDefaultSavePathChanged()) { + QSet affectedCatogories {{}}; // includes default (unnamed) category + for (auto it = m_categories.cbegin(); it != m_categories.cend(); ++it) + { + const QString &categoryName = it.key(); + const CategoryOptions &categoryOptions = it.value(); + if (categoryOptions.savePath.isRelative()) + affectedCatogories.insert(categoryName); + } + for (TorrentImpl *const torrent : asConst(m_torrents)) - torrent->setAutoTMMEnabled(false); - } - else - { - for (TorrentImpl *const torrent : asConst(m_torrents)) - torrent->handleCategoryOptionsChanged(); + { + if (affectedCatogories.contains(torrent->category())) + torrent->setAutoTMMEnabled(false); + } } + + m_savePath = newPath; + for (TorrentImpl *const torrent : asConst(m_torrents)) + torrent->handleCategoryOptionsChanged(); } void Session::setDownloadPath(const Path &path)