From 9b267690ccd4c1e5889414ad939bba45a64fab54 Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Thu, 6 Oct 2022 06:35:46 +0300 Subject: [PATCH] Don't pollute move queue by torrents w/o metadata There's really nothing to move if the torrent still doesn't have metadata. Additionally, such torrents in the queue can lead to unexpected behavior when reloading the torrent after metadata is received. PR #17823. --- src/base/bittorrent/torrentimpl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index ca3b650cc..839e0702d 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -501,6 +501,9 @@ void TorrentImpl::setAutoTMMEnabled(bool enabled) QString TorrentImpl::actualStorageLocation() const { + if (!hasMetadata()) + return {}; + return Utils::Fs::toUniformPath(QString::fromStdString(m_nativeStatus.save_path)); } @@ -1634,6 +1637,12 @@ void TorrentImpl::resume(const TorrentOperatingMode mode) void TorrentImpl::moveStorage(const QString &newPath, const MoveStorageMode mode) { + if (!hasMetadata()) + { + m_session->handleTorrentSavePathChanged(this); + return; + } + if (m_session->addMoveTorrentStorageJob(this, Utils::Fs::toNativePath(newPath), mode)) { m_storageIsMoving = true;