From dfaf263d6645406d43678abd2bcc4a7fd8f53af4 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 12 Feb 2008 19:51:45 +0000 Subject: [PATCH] Fix preferences to actually set global per torrent download/upload speeds. Apply global per torrent download/upload speeds to all torrents on change. --- deluge/core/torrent.py | 4 ++-- deluge/core/torrentmanager.py | 24 +++++++++++++++++------- deluge/ui/gtkui/preferences.py | 6 ++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 4e4ce905a..b2fd84b7b 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -116,11 +116,11 @@ class Torrent: self.handle.set_max_uploads(max_slots) def set_max_upload_speed(self, m_up_speed): - self.set_max_upload_speed = m_up_speed + self.max_upload_speed = m_up_speed self.handle.set_upload_limit(int(m_up_speed * 1024)) def set_max_download_speed(self, m_down_speed): - self.set_max_download_speed = m_down_speed + self.max_download_speed = m_down_speed self.handle.set_download_limit(int(m_down_speed * 1024)) def set_private_flag(self, private): diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 78209c32b..36f38e182 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -76,9 +76,7 @@ class TorrentManager(component.Component): self.alerts = alerts # Get the core config self.config = ConfigManager("core.conf") - # Per torrent connection limit and upload slot limit - self.max_connections = -1 - self.max_uploads = -1 + # Create the torrents dict { torrent_id: Torrent } self.torrents = {} @@ -87,7 +85,11 @@ class TorrentManager(component.Component): self.on_set_max_connections_per_torrent) self.config.register_set_function("max_upload_slots_per_torrent", self.on_set_max_upload_slots_per_torrent) - + self.config.register_set_function("max_upload_speed_per_torrent", + self.on_set_max_upload_speed_per_torrent) + self.config.register_set_function("max_download_speed_per_torrent", + self.on_set_max_download_speed_per_torrent) + # Register alert functions self.alerts.register_handler("torrent_finished_alert", self.on_alert_torrent_finished) @@ -435,17 +437,25 @@ class TorrentManager(component.Component): def on_set_max_connections_per_torrent(self, key, value): """Sets the per-torrent connection limit""" log.debug("max_connections_per_torrent set to %s..", value) - self.max_connections = value for key in self.torrents.keys(): self.torrents[key].set_max_connections(value) def on_set_max_upload_slots_per_torrent(self, key, value): """Sets the per-torrent upload slot limit""" log.debug("max_upload_slots_per_torrent set to %s..", value) - self.max_uploads = value for key in self.torrents.keys(): - self.torrents[key].set_max_uploads(value) + self.torrents[key].set_max_upload_slots(value) + def on_set_max_upload_speed_per_torrent(self, key, value): + log.debug("max_upload_speed_per_torrent set to %s..", value) + for key in self.torrents.keys(): + self.torrents[key].set_max_upload_speed(value) + + def on_set_max_download_speed_per_torrent(self, key, value): + log.debug("max_download_speed_per_torrent set to %s..", value) + for key in self.torrents.keys(): + self.torrents[key].set_max_download_speed(value) + ## Alert handlers ## def on_alert_torrent_finished(self, alert): log.debug("on_alert_torrent_finished") diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 1b24ba4b8..3f6cbd850 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -418,6 +418,12 @@ class Preferences(component.Component): new_core_config["max_upload_slots_per_torrent"] = \ self.glade.get_widget( "spin_max_upload_slots_per_torrent").get_value_as_int() + new_core_config["max_upload_speed_per_torrent"] = \ + self.glade.get_widget( + "spin_max_upload_per_torrent").get_value() + new_core_config["max_download_speed_per_torrent"] = \ + self.glade.get_widget( + "spin_max_download_per_torrent").get_value() ## Interface tab ## new_gtkui_config["enable_system_tray"] = \