From 4f20769a6c0571837f4896b7da5dc5ea14390df5 Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Fri, 22 Oct 2021 05:51:11 +0300 Subject: [PATCH] Use respective subcategory for "watched" torrents Assign respective Subcategory of configured Category to torrents if Automatic Torrent Management Mode is set for Watched folder. PR #15603. --- src/base/torrentfileswatcher.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/base/torrentfileswatcher.cpp b/src/base/torrentfileswatcher.cpp index afac49c6d..f879f0803 100644 --- a/src/base/torrentfileswatcher.cpp +++ b/src/base/torrentfileswatcher.cpp @@ -504,7 +504,15 @@ void TorrentFilesWatcher::Worker::processFolder(const QString &path, const QStri if (path != watchedFolderPath) { const QString subdirPath = watchedDir.relativeFilePath(path); - addTorrentParams.savePath = QDir::cleanPath(QDir(addTorrentParams.savePath).filePath(subdirPath)); + if (addTorrentParams.useAutoTMM) + { + addTorrentParams.category = addTorrentParams.category.isEmpty() + ? subdirPath : (addTorrentParams.category + QLatin1Char('/') + subdirPath); + } + else + { + addTorrentParams.savePath = QDir::cleanPath(QDir(addTorrentParams.savePath).filePath(subdirPath)); + } } if (filePath.endsWith(QLatin1String(".magnet"), Qt::CaseInsensitive)) @@ -575,7 +583,15 @@ void TorrentFilesWatcher::Worker::processFailedTorrents() if (exactDirPath != dir.path()) { const QString subdirPath = dir.relativeFilePath(exactDirPath); - addTorrentParams.savePath = QDir(addTorrentParams.savePath).filePath(subdirPath); + if (addTorrentParams.useAutoTMM) + { + addTorrentParams.category = addTorrentParams.category.isEmpty() + ? subdirPath : (addTorrentParams.category + QLatin1Char('/') + subdirPath); + } + else + { + addTorrentParams.savePath = QDir(addTorrentParams.savePath).filePath(subdirPath); + } } emit torrentFound(result.value(), addTorrentParams);