From 711be50e9c97476c845d88eb38826eb25a2f7aa5 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Mon, 24 Apr 2017 11:59:16 +0300 Subject: [PATCH 1/2] Fix AddTorrentData field types --- src/base/bittorrent/session.cpp | 14 +++++--------- src/base/bittorrent/torrenthandle.cpp | 9 +++++++-- src/base/bittorrent/torrenthandle.h | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 3f8e52239..09e3bc22f 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -3372,8 +3372,8 @@ void Session::createTorrentHandle(const libt::torrent_handle &nativeHandle) bool fromMagnetUri = !torrent->hasMetadata(); if (data.resumed) { - if (fromMagnetUri && (data.addPaused != TriStateBool::True)) - torrent->resume(data.addForced == TriStateBool::True); + if (fromMagnetUri && !data.addPaused) + torrent->resume(data.addForced); logger->addMessage(tr("'%1' resumed. (fast resume)", "'torrent name' was resumed. (fast resume)") .arg(torrent->name())); @@ -3399,12 +3399,8 @@ void Session::createTorrentHandle(const libt::torrent_handle &nativeHandle) if (isAddTrackersEnabled() && !torrent->isPrivate()) torrent->addTrackers(m_additionalTrackerList); - bool addPaused = (data.addPaused == TriStateBool::True); - if (data.addPaused == TriStateBool::Undefined) - addPaused = isAddTorrentPaused(); - // Start torrent because it was added in paused state - if (!addPaused) + if (!data.addPaused) torrent->resume(); logger->addMessage(tr("'%1' added to download list.", "'torrent name' was added to download list.") .arg(torrent->name())); @@ -3664,8 +3660,8 @@ namespace torrentData.hasRootFolder = fast.dict_find_int_value("qBt-hasRootFolder"); magnetUri = MagnetUri(QString::fromStdString(fast.dict_find_string_value("qBt-magnetUri"))); - torrentData.addPaused = TriStateBool(fast.dict_find_int_value("qBt-paused")); - torrentData.addForced = TriStateBool(fast.dict_find_int_value("qBt-forced")); + torrentData.addPaused = fast.dict_find_int_value("qBt-paused"); + torrentData.addForced = fast.dict_find_int_value("qBt-forced"); prio = fast.dict_find_int_value("qBt-queuePosition"); diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 41f3fbf4a..329a89957 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -76,6 +76,9 @@ AddTorrentData::AddTorrentData() , sequential(false) , hasSeedStatus(false) , skipChecking(false) + , hasRootFolder(true) + , addForced(false) + , addPaused(false) , ratioLimit(TorrentHandle::USE_GLOBAL_RATIO) { } @@ -90,8 +93,10 @@ AddTorrentData::AddTorrentData(const AddTorrentParams ¶ms) , hasSeedStatus(params.skipChecking) // do not react on 'torrent_finished_alert' when skipping , skipChecking(params.skipChecking) , hasRootFolder(params.createSubfolder) - , addForced(params.addForced) - , addPaused(params.addPaused) + , addForced(params.addForced == TriStateBool::True) + , addPaused(params.addPaused == TriStateBool::Undefined + ? Session::instance()->isAddTorrentPaused() + : params.addPaused == TriStateBool::True) , filePriorities(params.filePriorities) , ratioLimit(params.ignoreShareRatio ? TorrentHandle::NO_RATIO_LIMIT : TorrentHandle::USE_GLOBAL_RATIO) { diff --git a/src/base/bittorrent/torrenthandle.h b/src/base/bittorrent/torrenthandle.h index f8226bcb1..5f3afa7b7 100644 --- a/src/base/bittorrent/torrenthandle.h +++ b/src/base/bittorrent/torrenthandle.h @@ -99,8 +99,8 @@ namespace BitTorrent bool hasSeedStatus; bool skipChecking; bool hasRootFolder; - TriStateBool addForced; - TriStateBool addPaused; + bool addForced; + bool addPaused; // for new torrents QVector filePriorities; // for resumed torrents From c799923d7dcb6d2ff2d0c9af0aa17256ff9df7f8 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Mon, 24 Apr 2017 12:03:35 +0300 Subject: [PATCH 2/2] Allow strip root folder using default settings --- src/base/bittorrent/session.h | 2 +- src/base/bittorrent/torrenthandle.cpp | 4 +++- src/gui/addnewtorrentdialog.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index e1cb3d9e1..b65a70063 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -147,7 +147,7 @@ namespace BitTorrent QVector filePriorities; // used if TorrentInfo is set bool ignoreShareRatio = false; bool skipChecking = false; - bool createSubfolder = true; + TriStateBool createSubfolder; }; struct TorrentStatusReport diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 329a89957..5a2255bf0 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -92,7 +92,9 @@ AddTorrentData::AddTorrentData(const AddTorrentParams ¶ms) , sequential(params.sequential) , hasSeedStatus(params.skipChecking) // do not react on 'torrent_finished_alert' when skipping , skipChecking(params.skipChecking) - , hasRootFolder(params.createSubfolder) + , hasRootFolder(params.createSubfolder == TriStateBool::Undefined + ? Session::instance()->isCreateTorrentSubfolder() + : params.createSubfolder == TriStateBool::True) , addForced(params.addForced == TriStateBool::True) , addPaused(params.addPaused == TriStateBool::Undefined ? Session::instance()->isAddTorrentPaused() diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 170c5e504..b33814550 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -642,7 +642,7 @@ void AddNewTorrentDialog::accept() params.filePriorities = m_contentModel->model()->getFilePriorities(); params.addPaused = TriStateBool(!ui->startTorrentCheckBox->isChecked()); - params.createSubfolder = ui->createSubfolderCheckBox->isChecked(); + params.createSubfolder = TriStateBool(ui->createSubfolderCheckBox->isChecked()); QString savePath = ui->savePathComboBox->itemData(ui->savePathComboBox->currentIndex()).toString(); if (ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.