From db4ef67cff8372dba5427e2e194609db5357a8cf Mon Sep 17 00:00:00 2001 From: Alex Dedul Date: Fri, 10 Aug 2007 22:42:53 +0000 Subject: [PATCH] Get not cached torrent state in core.apply_queue(). --- src/core.py | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/core.py b/src/core.py index 471df9104..315169fa7 100644 --- a/src/core.py +++ b/src/core.py @@ -501,28 +501,6 @@ class Manager: # altering max_active_torrents), or just from time to time # ___ALL queuing code should be in this function, and ONLY here___ def apply_queue(self): - # Handle autoseeding - downqueue as needed - if not self.get_pref('clear_max_ratio_torrents') \ - and self.get_pref('auto_seed_ratio') > 0 \ - and self.get_pref('auto_end_seeding'): - - for unique_ID in self.unique_IDs: - torrent_state = self.get_core_torrent_state(unique_ID) - if torrent_state['is_seed'] and not torrent_state['is_paused']: - ratio = self.calc_ratio(unique_ID, torrent_state) - if ratio >= self.get_pref('auto_seed_ratio'): - self.queue_bottom(unique_ID, enforce_queue=False) # don't recurse! - self.set_user_pause(unique_ID, True, enforce_queue=False) - - if self.get_pref('clear_max_ratio_torrents'): - for unique_ID in self.state.queue: - torrent_state = self.get_core_torrent_state(unique_ID) - if torrent_state['is_seed']: - ratio = self.calc_ratio(unique_ID, torrent_state) - if ratio >= self.get_pref('auto_seed_ratio'): - self.removed_unique_ids[unique_ID] = 1 - self.remove_torrent(unique_ID, False, True) - # Counter for currently active torrent in the queue. Paused in core # but having self.is_user_paused(unique_ID) == False is # also considered active. @@ -530,7 +508,10 @@ class Manager: # Pause and resume torrents for unique_ID in self.state.queue: - torrent_state = self.get_core_torrent_state(unique_ID) + # Get not cached torrent state so we don't pause/resume torrents + # more than 1 time - if cached torrent_state['is_paused'] can be + # still paused after we already paused it. + torrent_state = self.get_core_torrent_state(unique_ID, False) if not torrent_state['is_paused'] or \ (torrent_state['is_paused'] and not \ @@ -564,6 +545,28 @@ class Manager: self.is_user_paused(unique_ID)): self.pause(unique_ID) + # Handle autoseeding - downqueue as needed + if not self.get_pref('clear_max_ratio_torrents') \ + and self.get_pref('auto_seed_ratio') > 0 \ + and self.get_pref('auto_end_seeding'): + + for unique_ID in self.unique_IDs: + torrent_state = self.get_core_torrent_state(unique_ID) + if torrent_state['is_seed'] and not torrent_state['is_paused']: + ratio = self.calc_ratio(unique_ID, torrent_state) + if ratio >= self.get_pref('auto_seed_ratio'): + self.queue_bottom(unique_ID, enforce_queue=False) # don't recurse! + self.set_user_pause(unique_ID, True, enforce_queue=False) + + if self.get_pref('clear_max_ratio_torrents'): + for unique_ID in self.state.queue: + torrent_state = self.get_core_torrent_state(unique_ID) + if torrent_state['is_seed']: + ratio = self.calc_ratio(unique_ID, torrent_state) + if ratio >= self.get_pref('auto_seed_ratio'): + self.removed_unique_ids[unique_ID] = 1 + self.remove_torrent(unique_ID, False, True) + # Event handling def connect_event(self, event_type, callback):