diff --git a/src/core/download.cc b/src/core/download.cc index 6a3e3c5e..c3b78ba3 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -52,10 +52,13 @@ Download::Download() : void Download::start() { - if (is_done()) + if (is_done()) { m_download.set_connection_type(m_connectionSeed); - else + torrent::download_set_priority(m_download, 2); + } else { m_download.set_connection_type(m_connectionLeech); + torrent::download_set_priority(m_download, 4); + } m_download.start(); } @@ -98,6 +101,7 @@ Download::release_download() { void Download::receive_finished() { m_download.set_connection_type(m_connectionSeed); + torrent::download_set_priority(m_download, 2); } void diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index 143cbe7a..8d77b599 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -41,6 +41,7 @@ #include #include "core/manager.h" +#include "ui/root.h" #include "utils/directory.h" #include "control.h" @@ -146,12 +147,12 @@ apply_connection_seed(Control* m, const std::string& arg) { void apply_global_download_rate(Control* m, int arg) { - torrent::set_down_throttle(arg * 1024); + m->ui()->receive_down_throttle(arg); } void apply_global_upload_rate(Control* m, int arg) { - torrent::set_up_throttle(arg * 1024); + m->ui()->receive_up_throttle(arg); } void diff --git a/src/ui/root.cc b/src/ui/root.cc index e437ceaa..840a15c5 100644 --- a/src/ui/root.cc +++ b/src/ui/root.cc @@ -114,27 +114,29 @@ Root::setup_keys() { void Root::receive_down_throttle(int t) { - m_windowStatusbar->mark_dirty(); + if (m_windowStatusbar != NULL) + m_windowStatusbar->mark_dirty(); torrent::set_down_throttle(std::max(torrent::get_down_throttle() + t * 1024, 0)); } void Root::receive_up_throttle(int t) { - m_windowStatusbar->mark_dirty(); + if (m_windowStatusbar != NULL) + m_windowStatusbar->mark_dirty(); uint32_t throttle = std::max(torrent::get_up_throttle() + t * 1024, 0); torrent::set_up_throttle(throttle); -// if (throttle == 0) -// torrent::set_max_unchoked(0); + if (throttle == 0) + torrent::set_max_unchoked(0); -// else if (throttle <= 10 << 10) -// torrent::set_max_unchoked(1 + throttle / (1 << 10)); + else if (throttle <= 10 << 10) + torrent::set_max_unchoked(1 + throttle / (1 << 10)); -// else -// torrent::set_max_unchoked(10 + throttle / (5 << 10)); + else + torrent::set_max_unchoked(10 + throttle / (5 << 10)); } } diff --git a/src/ui/root.h b/src/ui/root.h index e435a4c7..1e784c04 100644 --- a/src/ui/root.h +++ b/src/ui/root.h @@ -60,12 +60,12 @@ public: WStatusbar* window_statusbar() { return m_windowStatusbar; } -private: - void setup_keys(); - void receive_down_throttle(int t); void receive_up_throttle(int t); +private: + void setup_keys(); + Control* m_control; DownloadList* m_downloadList;