Fix Incomplete Save Path cannot be changed for torrents without metadata

PR #21152.
Closes #21140.
This commit is contained in:
Vladimir Golovnev 2024-08-08 08:20:26 +03:00 committed by GitHub
parent cbabe56fcf
commit bee56f2567
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -470,6 +470,8 @@ Path TorrentImpl::savePath() const
void TorrentImpl::setSavePath(const Path &path) void TorrentImpl::setSavePath(const Path &path)
{ {
Q_ASSERT(!isAutoTMMEnabled()); Q_ASSERT(!isAutoTMMEnabled());
if (isAutoTMMEnabled()) [[unlikely]]
return;
const Path basePath = m_session->useCategoryPathsInManualMode() const Path basePath = m_session->useCategoryPathsInManualMode()
? m_session->categorySavePath(category()) : m_session->savePath(); ? m_session->categorySavePath(category()) : m_session->savePath();
@ -497,6 +499,8 @@ Path TorrentImpl::downloadPath() const
void TorrentImpl::setDownloadPath(const Path &path) void TorrentImpl::setDownloadPath(const Path &path)
{ {
Q_ASSERT(!isAutoTMMEnabled()); Q_ASSERT(!isAutoTMMEnabled());
if (isAutoTMMEnabled()) [[unlikely]]
return;
const Path basePath = m_session->useCategoryPathsInManualMode() const Path basePath = m_session->useCategoryPathsInManualMode()
? m_session->categoryDownloadPath(category()) : m_session->downloadPath(); ? m_session->categoryDownloadPath(category()) : m_session->downloadPath();
@ -1968,8 +1972,17 @@ void TorrentImpl::moveStorage(const Path &newPath, const MoveStorageContext cont
{ {
if (!hasMetadata()) if (!hasMetadata())
{ {
m_savePath = newPath; if (context == MoveStorageContext::ChangeSavePath)
m_session->handleTorrentSavePathChanged(this); {
m_savePath = newPath;
m_session->handleTorrentSavePathChanged(this);
}
else if (context == MoveStorageContext::ChangeDownloadPath)
{
m_downloadPath = newPath;
m_session->handleTorrentSavePathChanged(this);
}
return; return;
} }