From 6da46bc546c8b37caaaae1ae26af1494f13ae299 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sat, 10 Nov 2007 02:46:27 +0000 Subject: [PATCH] Add separate preference for max downloading torrents and max seeding torrents --- TODO | 1 - glade/preferences_dialog.glade | 86 +++++++++++++++++++++++++++++----- src/core.py | 25 ++++++---- src/dialogs.py | 2 + src/pref.py | 2 + 5 files changed, 93 insertions(+), 23 deletions(-) diff --git a/TODO b/TODO index 69df0bdd4..2268dfc6e 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ for 0.5.7 * remap filenames * decide what to do about the progress bar patch - * distinguish between total seeding torrents and total active torrents diff --git a/glade/preferences_dialog.glade b/glade/preferences_dialog.glade index 7d93b9350..03413a094 100644 --- a/glade/preferences_dialog.glade +++ b/glade/preferences_dialog.glade @@ -245,23 +245,29 @@ True The number of active torrents that Deluge will run. Set to -1 for unlimited. 0 - Maximum simultaneous active torrents: + Maximum simultaneous downloading torrents: False - + True - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - The number of active torrents that Deluge will run. Set to -1 for unlimited. - 1 - -1 -1 1000 1 10 10 - 1 - True - GTK_UPDATE_IF_VALID + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + The number of active torrents that Deluge will run. Set to -1 for unlimited. + 1 + -1 -1 1000 1 10 10 + 1 + True + GTK_UPDATE_IF_VALID + + False @@ -271,6 +277,51 @@ + + + True + 10 + + + True + The number of active torrents that Deluge will run. Set to -1 for unlimited. + 0 + Maximum simultaneous seeding torrents: + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 32 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + The number of active torrents that Deluge will run. Set to -1 for unlimited. + 1 + -1 -1 1000 1 10 10 + 1 + True + GTK_UPDATE_IF_VALID + + + + + False + 2 + 1 + + + + + 1 + + True @@ -283,7 +334,7 @@ False - 1 + 2 @@ -298,7 +349,7 @@ False - 2 + 3 @@ -878,11 +929,18 @@ Forced - + True - Handshake + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 7 + + + True + Handshake Full Stream Either + + 6 @@ -1252,6 +1310,7 @@ Either 1 0 -1 9000 1 10 10 1 + 1 1 @@ -1269,6 +1328,7 @@ Either 1 0 -1 9000 1 10 10 1 + 1 1 diff --git a/src/core.py b/src/core.py index 1adf4ea86..934fb7e1c 100644 --- a/src/core.py +++ b/src/core.py @@ -505,6 +505,7 @@ class Manager: # but having self.is_user_paused(unique_ID) == False is # also considered active. active_torrent_cnt = 0 + seed_torrent_cnt = 0 # Pause and resume torrents for torrent in self.state.queue: @@ -516,18 +517,23 @@ class Manager: if not torrent_state['is_paused'] or \ (torrent_state['is_paused'] and not \ - self.is_user_paused(unique_ID)): + self.is_user_paused(unique_ID)) and not torrent_state['is_seed']: active_torrent_cnt += 1 - + + if torrent_state['is_seed'] and not self.is_user_paused(unique_ID): + seed_torrent_cnt += 1 + + if (seed_torrent_cnt <= self.get_pref('max_seeding_torrents')) or (self.get_pref('max_seeding_torrents') == -1): + self.resume(unique_ID) + + if (seed_torrent_cnt > self.get_pref('max_seeding_torrents')) and (self.get_pref('max_seeding_torrents') != -1): + self.pause(unique_ID) + if (active_torrent_cnt <= self.get_pref('max_active_torrents') or \ self.get_pref('max_active_torrents') == -1) and \ torrent_state['is_paused'] and not \ - self.is_user_paused(unique_ID): - # This torrent is a seed so skip all the free space checking - if torrent_state['is_seed']: - self.resume(unique_ID) - continue - + self.is_user_paused(unique_ID) and not torrent_state['is_seed']: + # Before we resume, we should check if the torrent is using Full Allocation # and if there is enough space on to finish this file. if not self.unique_IDs[unique_ID].compact: @@ -547,10 +553,11 @@ of HD space! Oops!\nWe had to pause at least one torrent")) print "Not enough free space to resume this torrent!" else: #We're using compact allocation so lets just resume self.resume(unique_ID) + elif not torrent_state['is_paused'] and \ ((active_torrent_cnt > self.get_pref('max_active_torrents') and \ self.get_pref('max_active_torrents') != -1) or \ - self.is_user_paused(unique_ID)): + self.is_user_paused(unique_ID)) and not torrent_state['is_seed']: self.pause(unique_ID) # Handle autoseeding - downqueue as needed diff --git a/src/dialogs.py b/src/dialogs.py index 8fe32eb09..9f978620f 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -144,6 +144,7 @@ class PreferencesDlg: self.glade.get_widget("spin_web_proxy_port").set_value(self.preferences.get("web_proxy_port")) self.glade.get_widget("spin_max_half_open").set_value(float(self.preferences.get("max_half_open"))) self.glade.get_widget("spin_torrents").set_value(float(self.preferences.get("max_active_torrents"))) + self.glade.get_widget("spin_seed").set_value(float(self.preferences.get("max_seeding_torrents"))) self.glade.get_widget("chk_seedbottom").set_active(self.preferences.get("queue_seeds_to_bottom")) self.glade.get_widget("chk_queue_above_completed").set_sensitive(self.preferences.get("queue_seeds_to_bottom")) self.glade.get_widget("chk_queue_above_completed").set_active(self.preferences.get("queue_above_completed")) @@ -264,6 +265,7 @@ class PreferencesDlg: self.preferences.set("max_connections_per_torrent", int(self.glade.get_widget("spin_max_connections_per_torrent").get_value())) self.preferences.set("max_half_open", int(self.glade.get_widget("spin_max_half_open").get_value())) self.preferences.set("max_active_torrents", int(self.glade.get_widget("spin_torrents").get_value())) + self.preferences.set("max_seeding_torrents", int(self.glade.get_widget("spin_seed").get_value())) self.preferences.set("queue_seeds_to_bottom", self.glade.get_widget("chk_seedbottom").get_active()) self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active()) self.preferences.set("gui_update_interval", self.glade.get_widget("spin_gui").get_value()) diff --git a/src/pref.py b/src/pref.py index 5199123dc..03c106323 100644 --- a/src/pref.py +++ b/src/pref.py @@ -70,6 +70,7 @@ if common.windows_check(): "lock_tray" : False, "max_half_open" : 8, "max_active_torrents" : 8, + "max_seeding_torrents" : 8, "max_connections_global" : 200, "max_connections_per_torrent" : -1, "max_download_speed" : -1, @@ -179,6 +180,7 @@ else: "lock_tray" : False, "max_half_open" : 8, "max_active_torrents" : 8, + "max_seeding_torrents" : 8, "max_connections_global" : 200, "max_connections_per_torrent" : -1, "max_download_speed" : -1,