mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 14:38:04 -06:00
Allow to set torrent stop condition
PR #17814. Closes #17792. Closes #929. (Actually it should close all issues about lack of ability to stop torrent after metadata downloaded or after files are initially checked.) Also makes explicit the temporary start of the torrent in the case when recheck of the stopped torrent is performed.
This commit is contained in:
committed by
GitHub
parent
ce7d8dee28
commit
67357e9964
@@ -245,6 +245,9 @@ BitTorrent::LoadResumeDataResult BitTorrent::BencodeResumeDataStorage::loadTorre
|
||||
// fromLTString(root.dict_find_string_value("qBt-contentLayout")), TorrentContentLayout::Default);
|
||||
// === END REPLACEMENT CODE === //
|
||||
|
||||
torrentParams.stopCondition = Utils::String::toEnum(
|
||||
fromLTString(resumeDataRoot.dict_find_string_value("qBt-stopCondition")), Torrent::StopCondition::None);
|
||||
|
||||
const lt::string_view ratioLimitString = resumeDataRoot.dict_find_string_value("qBt-ratioLimit");
|
||||
if (ratioLimitString.empty())
|
||||
torrentParams.ratioLimit = resumeDataRoot.dict_find_int_value("qBt-ratioLimit", Torrent::USE_GLOBAL_RATIO * 1000) / 1000.0;
|
||||
@@ -284,20 +287,14 @@ BitTorrent::LoadResumeDataResult BitTorrent::BencodeResumeDataStorage::loadTorre
|
||||
p.save_path = Profile::instance()->fromPortablePath(
|
||||
Path(fromLTString(p.save_path))).toString().toStdString();
|
||||
|
||||
torrentParams.stopped = (p.flags & lt::torrent_flags::paused) && !(p.flags & lt::torrent_flags::auto_managed);
|
||||
torrentParams.operatingMode = (p.flags & lt::torrent_flags::paused) || (p.flags & lt::torrent_flags::auto_managed)
|
||||
? TorrentOperatingMode::AutoManaged : TorrentOperatingMode::Forced;
|
||||
|
||||
if (p.flags & lt::torrent_flags::stop_when_ready)
|
||||
{
|
||||
// If torrent has "stop_when_ready" flag set then it is actually "stopped"
|
||||
torrentParams.stopped = true;
|
||||
torrentParams.operatingMode = TorrentOperatingMode::AutoManaged;
|
||||
// ...but temporarily "resumed" to perform some service jobs (e.g. checking)
|
||||
p.flags &= ~lt::torrent_flags::paused;
|
||||
p.flags |= lt::torrent_flags::auto_managed;
|
||||
}
|
||||
else
|
||||
{
|
||||
torrentParams.stopped = (p.flags & lt::torrent_flags::paused) && !(p.flags & lt::torrent_flags::auto_managed);
|
||||
torrentParams.operatingMode = (p.flags & lt::torrent_flags::paused) || (p.flags & lt::torrent_flags::auto_managed)
|
||||
? TorrentOperatingMode::AutoManaged : TorrentOperatingMode::Forced;
|
||||
p.flags &= ~lt::torrent_flags::stop_when_ready;
|
||||
torrentParams.stopCondition = Torrent::StopCondition::FilesChecked;
|
||||
}
|
||||
|
||||
const bool hasMetadata = (p.ti && p.ti->is_valid());
|
||||
@@ -393,6 +390,7 @@ void BitTorrent::BencodeResumeDataStorage::Worker::store(const TorrentID &id, co
|
||||
data["qBt-seedStatus"] = resumeData.hasSeedStatus;
|
||||
data["qBt-contentLayout"] = Utils::String::fromEnum(resumeData.contentLayout).toStdString();
|
||||
data["qBt-firstLastPiecePriority"] = resumeData.firstLastPiecePriority;
|
||||
data["qBt-stopCondition"] = Utils::String::fromEnum(resumeData.stopCondition).toStdString();
|
||||
|
||||
if (!resumeData.useAutoTMM)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user