Browse Source

adding a save resume data interval option

because some SSD users oppose frequent disk writes
adaptive-webui-19844
John S. Peterson 11 years ago committed by John Sebastian Peterson
parent
commit
d27bff4df4
  1. 12
      src/preferences/advancedsettings.h
  2. 8
      src/preferences/preferences.cpp
  3. 2
      src/preferences/preferences.h
  4. 3
      src/qtlibtorrent/qbtsession.cpp

12
src/preferences/advancedsettings.h

@ -13,7 +13,7 @@
#include "preferences.h" #include "preferences.h"
enum AdvSettingsCols {PROPERTY, VALUE}; enum AdvSettingsCols {PROPERTY, VALUE};
enum AdvSettingsRows {DISK_CACHE, DISK_CACHE_TTL, OS_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_LISTEN_IPV6, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT, enum AdvSettingsRows {DISK_CACHE, DISK_CACHE_TTL, OS_CACHE, SAVE_RESUME_DATA_INTERVAL, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_LISTEN_IPV6, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT,
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) #if defined(Q_OS_WIN) || defined(Q_OS_MAC)
UPDATE_CHECK, UPDATE_CHECK,
#endif #endif
@ -28,7 +28,7 @@ class AdvancedSettings: public QTableWidget {
Q_OBJECT Q_OBJECT
private: private:
QSpinBox spin_cache, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port; QSpinBox spin_cache, spin_save_resume_data_interval, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port;
QCheckBox cb_os_cache, cb_ignore_limits_lan, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, QCheckBox cb_os_cache, cb_ignore_limits_lan, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts,
cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion, cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion,
cb_enable_tracker_ext, cb_listen_ipv6; cb_enable_tracker_ext, cb_listen_ipv6;
@ -73,6 +73,8 @@ public slots:
pref->setDiskCacheTTL(spin_cache_ttl.value()); pref->setDiskCacheTTL(spin_cache_ttl.value());
// Enable OS cache // Enable OS cache
pref->setOsCache(cb_os_cache.isChecked()); pref->setOsCache(cb_os_cache.isChecked());
// Save resume data interval
pref->setSaveResumeDataInterval(spin_save_resume_data_interval.value());
// Outgoing ports // Outgoing ports
pref->setOutgoingPortsMin(outgoing_ports_min.value()); pref->setOutgoingPortsMin(outgoing_ports_min.value());
pref->setOutgoingPortsMax(outgoing_ports_max.value()); pref->setOutgoingPortsMax(outgoing_ports_max.value());
@ -195,6 +197,12 @@ private slots:
// Enable OS cache // Enable OS cache
cb_os_cache.setChecked(pref->osCache()); cb_os_cache.setChecked(pref->osCache());
setRow(OS_CACHE, tr("Enable OS cache"), &cb_os_cache); setRow(OS_CACHE, tr("Enable OS cache"), &cb_os_cache);
// Save resume data interval
spin_save_resume_data_interval.setMinimum(1);
spin_save_resume_data_interval.setMaximum(1440);
spin_save_resume_data_interval.setValue(pref->saveResumeDataInterval());
spin_save_resume_data_interval.setSuffix(tr(" m", " minutes"));
setRow(SAVE_RESUME_DATA_INTERVAL, tr("Save resume data interval"), &spin_save_resume_data_interval);
// Outgoing port Min // Outgoing port Min
outgoing_ports_min.setMinimum(0); outgoing_ports_min.setMinimum(0);
outgoing_ports_min.setMaximum(65535); outgoing_ports_min.setMaximum(65535);

8
src/preferences/preferences.cpp

@ -1157,6 +1157,14 @@ void Preferences::setOsCache(bool enable) {
setValue("Preferences/Advanced/osCache", enable); setValue("Preferences/Advanced/osCache", enable);
} }
uint Preferences::saveResumeDataInterval() const {
return value("Preferences/Downloads/SaveResumeDataInterval", 3).toUInt();
}
void Preferences::setSaveResumeDataInterval(uint m) {
setValue("Preferences/Downloads/SaveResumeDataInterval", m);
}
uint Preferences::outgoingPortsMin() const { uint Preferences::outgoingPortsMin() const {
return value("Preferences/Advanced/OutgoingPortsMin", 0).toUInt(); return value("Preferences/Advanced/OutgoingPortsMin", 0).toUInt();
} }

2
src/preferences/preferences.h

@ -316,6 +316,8 @@ public:
void setDiskCacheTTL(uint ttl); void setDiskCacheTTL(uint ttl);
bool osCache() const; bool osCache() const;
void setOsCache(bool enable); void setOsCache(bool enable);
uint saveResumeDataInterval() const;
void setSaveResumeDataInterval(uint m);
uint outgoingPortsMin() const; uint outgoingPortsMin() const;
void setOutgoingPortsMin(uint val); void setOutgoingPortsMin(uint val);
uint outgoingPortsMax() const; uint outgoingPortsMax() const;

3
src/qtlibtorrent/qbtsession.cpp

@ -166,7 +166,7 @@ QBtSession::QBtSession()
connect(downloader, SIGNAL(magnetRedirect(QString, QString)), SLOT(handleMagnetRedirect(QString, QString))); connect(downloader, SIGNAL(magnetRedirect(QString, QString)), SLOT(handleMagnetRedirect(QString, QString)));
// Regular saving of fastresume data // Regular saving of fastresume data
connect(&resumeDataTimer, SIGNAL(timeout()), SLOT(saveTempFastResumeData())); connect(&resumeDataTimer, SIGNAL(timeout()), SLOT(saveTempFastResumeData()));
resumeDataTimer.start(170000); // 3min resumeDataTimer.start(pref->saveResumeDataInterval() * 60 * 1000);
qDebug("* BTSession constructed"); qDebug("* BTSession constructed");
} }
@ -429,6 +429,7 @@ void QBtSession::configureSession() {
session_settings::io_buffer_mode_t mode = pref->osCache() ? session_settings::enable_os_cache : session_settings::disable_os_cache; session_settings::io_buffer_mode_t mode = pref->osCache() ? session_settings::enable_os_cache : session_settings::disable_os_cache;
sessionSettings.disk_io_read_mode = mode; sessionSettings.disk_io_read_mode = mode;
sessionSettings.disk_io_write_mode = mode; sessionSettings.disk_io_write_mode = mode;
resumeDataTimer.setInterval(pref->saveResumeDataInterval() * 60 * 1000);
sessionSettings.anonymous_mode = pref->isAnonymousModeEnabled(); sessionSettings.anonymous_mode = pref->isAnonymousModeEnabled();
if (sessionSettings.anonymous_mode) { if (sessionSettings.anonymous_mode) {
addConsoleMessage(tr("Anonymous mode [ON]"), "blue"); addConsoleMessage(tr("Anonymous mode [ON]"), "blue");

Loading…
Cancel
Save