Browse Source

Save ratio limits as int instead of string

adaptive-webui-19844
thalieht 7 years ago
parent
commit
0717f0d60c
  1. 2
      src/app/upgrade.h
  2. 8
      src/base/bittorrent/session.cpp
  3. 2
      src/base/bittorrent/torrenthandle.cpp

2
src/app/upgrade.h

@ -195,7 +195,7 @@ bool upgrade(bool ask = true)
resumeData["qBt-forced"] = false; resumeData["qBt-forced"] = false;
resumeData["qBt-savePath"] = oldTorrent.value("save_path").toString().toStdString(); resumeData["qBt-savePath"] = oldTorrent.value("save_path").toString().toStdString();
resumeData["qBt-ratioLimit"] = QString::number(oldTorrent.value("max_ratio", -2).toReal()).toStdString(); resumeData["qBt-ratioLimit"] = static_cast<int>(oldTorrent.value("max_ratio", -2).toReal() * 1000);
resumeData["qBt-label"] = oldTorrent.value("label").toString().toStdString(); resumeData["qBt-label"] = oldTorrent.value("label").toString().toStdString();
resumeData["qBt-name"] = oldTorrent.value("name").toString().toStdString(); resumeData["qBt-name"] = oldTorrent.value("name").toString().toStdString();
resumeData["qBt-seedStatus"] = oldTorrent.value("seed").toBool(); resumeData["qBt-seedStatus"] = oldTorrent.value("seed").toBool();

8
src/base/bittorrent/session.cpp

@ -31,6 +31,7 @@
#include <cstdlib> #include <cstdlib>
#include <queue> #include <queue>
#include <string>
#include <vector> #include <vector>
#include <QCoreApplication> #include <QCoreApplication>
@ -4371,7 +4372,12 @@ namespace
torrentData.savePath = Profile::instance().fromPortablePath( torrentData.savePath = Profile::instance().fromPortablePath(
Utils::Fs::fromNativePath(QString::fromStdString(fast.dict_find_string_value("qBt-savePath")))); Utils::Fs::fromNativePath(QString::fromStdString(fast.dict_find_string_value("qBt-savePath"))));
torrentData.ratioLimit = QString::fromStdString(fast.dict_find_string_value("qBt-ratioLimit")).toDouble();
std::string ratioLimitString = fast.dict_find_string_value("qBt-ratioLimit");
if (ratioLimitString.empty())
torrentData.ratioLimit = fast.dict_find_int_value("qBt-ratioLimit", TorrentHandle::USE_GLOBAL_RATIO * 1000) / 1000.0;
else
torrentData.ratioLimit = QString::fromStdString(ratioLimitString).toDouble();
torrentData.seedingTimeLimit = fast.dict_find_int_value("qBt-seedingTimeLimit", TorrentHandle::USE_GLOBAL_SEEDING_TIME); torrentData.seedingTimeLimit = fast.dict_find_int_value("qBt-seedingTimeLimit", TorrentHandle::USE_GLOBAL_SEEDING_TIME);
// ************************************************************************************** // **************************************************************************************
// Workaround to convert legacy label to category // Workaround to convert legacy label to category

2
src/base/bittorrent/torrenthandle.cpp

@ -1670,7 +1670,7 @@ void TorrentHandle::handleSaveResumeDataAlert(libtorrent::save_resume_data_alert
resumeData["save_path"] = Profile::instance().toPortablePath(QString::fromStdString(savePath)).toStdString(); resumeData["save_path"] = Profile::instance().toPortablePath(QString::fromStdString(savePath)).toStdString();
} }
resumeData["qBt-savePath"] = m_useAutoTMM ? "" : Profile::instance().toPortablePath(m_savePath).toStdString(); resumeData["qBt-savePath"] = m_useAutoTMM ? "" : Profile::instance().toPortablePath(m_savePath).toStdString();
resumeData["qBt-ratioLimit"] = QString::number(m_ratioLimit).toStdString(); resumeData["qBt-ratioLimit"] = static_cast<int>(m_ratioLimit * 1000);
resumeData["qBt-seedingTimeLimit"] = m_seedingTimeLimit; resumeData["qBt-seedingTimeLimit"] = m_seedingTimeLimit;
resumeData["qBt-category"] = m_category.toStdString(); resumeData["qBt-category"] = m_category.toStdString();
resumeData["qBt-tags"] = setToEntryList(m_tags); resumeData["qBt-tags"] = setToEntryList(m_tags);

Loading…
Cancel
Save