From 8f96d9318ab1a9abb88a1d0712d89d027d881624 Mon Sep 17 00:00:00 2001 From: Alex Dedul Date: Wed, 18 Jul 2007 19:12:29 +0000 Subject: [PATCH] Some fine tune tweaks to [1004]. --- src/core.py | 6 +++--- src/interface.py | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/core.py b/src/core.py index 4e82539d8..d00b93673 100644 --- a/src/core.py +++ b/src/core.py @@ -226,7 +226,7 @@ class Manager: self.event_callbacks = {} # unique_ids removed by core - self.removed_unique_ids = [] + self.removed_unique_ids = {} PREF_FUNCTIONS["enable_dht"] = self.set_DHT @@ -462,7 +462,7 @@ class Manager: torrent_state = self.get_core_torrent_state(unique_ID) if torrent_state['progress'] == 1.0: self.remove_torrent_ns(unique_ID) - self.removed_unique_ids.append(unique_ID) + self.removed_unique_ids[unique_ID] = 1 self.sync() self.apply_queue() @@ -492,7 +492,7 @@ class Manager: torrent_state = self.get_core_torrent_state(unique_ID, efficient) ratio = self.calc_ratio(unique_ID, torrent_state) if ratio >= self.get_pref('auto_seed_ratio'): - self.removed_unique_ids.append(unique_ID) + self.removed_unique_ids[unique_ID] = 1 self.remove_torrent(unique_ID, False, True) # Pause and resume torrents diff --git a/src/interface.py b/src/interface.py index 3724d57f7..79ccdb5a8 100644 --- a/src/interface.py +++ b/src/interface.py @@ -841,23 +841,25 @@ class DelugeGTK: while itr is not None: uid = self.torrent_model.get_value(itr, 0) - if self.manager.removed_unique_ids.count(uid) > 0: + + if uid in self.manager.removed_unique_ids: selected_unique_id = self.get_selected_torrent() - # If currently selected torrent was complete and so removed clear - # details pane + # If currently selected torrent was complete and so removed + # clear details pane if selected_unique_id == uid: self.clear_details_pane() + next = self.torrent_model.iter_next(itr) self.torrent_model.remove(itr) itr = self.torrent_model.get_iter_first() if itr is None: return True itr = next - self.manager.removed_unique_ids.pop(self.manager.removed_unique_ids.index(uid)) + + del self.manager.removed_unique_ids[uid] else: - state = self.manager.get_torrent_state(uid) tlist = self.get_list_from_unique_id(uid) - for i in range(len(tlist)): + for i in xrange(len(tlist)): try: self.torrent_model.set_value(itr, i, tlist[i]) except: