diff --git a/deluge/core/core.py b/deluge/core/core.py index ef7366747..f67c40ddf 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -420,9 +420,9 @@ class Core(component.Component): for torrent_id in torrent_ids: self.torrentmanager[torrent_id].resume() - def create_torrent_status(self, torrent_id, torrent_keys, plugin_keys, diff=False, update=False): + def create_torrent_status(self, torrent_id, torrent_keys, plugin_keys, diff=False, update=False, all_keys=False): try: - status = self.torrentmanager[torrent_id].get_status(torrent_keys, diff, update=update) + status = self.torrentmanager[torrent_id].get_status(torrent_keys, diff, update=update, all_keys=all_keys) except KeyError: import traceback traceback.print_exc() @@ -437,7 +437,7 @@ class Core(component.Component): @export def get_torrent_status(self, torrent_id, keys, diff=False): torrent_keys, plugin_keys = self.torrentmanager.separate_keys(keys, [torrent_id]) - return self.create_torrent_status(torrent_id, torrent_keys, plugin_keys, diff=diff, update=True) + return self.create_torrent_status(torrent_id, torrent_keys, plugin_keys, diff=diff, update=True, all_keys=not keys) @export def get_torrents_status(self, filter_dict, keys, diff=False): diff --git a/deluge/core/filtermanager.py b/deluge/core/filtermanager.py index c9545072c..cf5d235ba 100644 --- a/deluge/core/filtermanager.py +++ b/deluge/core/filtermanager.py @@ -155,7 +155,7 @@ class FilterManager(component.Component): if isinstance(value, basestring): filter_dict[key] = [value] - if "id"in filter_dict: #optimized filter for id: + if "id" in filter_dict: #optimized filter for id: torrent_ids = list(filter_dict["id"]) del filter_dict["id"] else: @@ -189,10 +189,11 @@ class FilterManager(component.Component): if not filter_dict: #return if there's nothing more to filter return torrent_ids + torrent_keys, plugin_keys = self.torrents.separate_keys(filter_dict.keys(), torrent_ids) #leftover filter arguments: #default filter on status fields. for torrent_id in list(torrent_ids): - status = self.torrents[torrent_id].get_status(filter_dict.keys()) #status={key:value} + status = self.core.create_torrent_status(torrent_id, torrent_keys, plugin_keys) for field, values in filter_dict.iteritems(): if (not status[field] in values) and torrent_id in torrent_ids: torrent_ids.remove(torrent_id) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 99ba11a0d..bf833f0bf 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -626,7 +626,7 @@ class Torrent(object): return host return "" - def get_status(self, keys, diff=False, update=False): + def get_status(self, keys, diff=False, update=False, all_keys=False): """ Returns the status of the torrent based on the keys provided @@ -646,7 +646,7 @@ class Torrent(object): if update: self.update_status(self.handle.status()) - if not keys: + if all_keys: keys = self.status_funcs.keys() status_dict = {} diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 1a458d785..486565d76 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -1151,7 +1151,7 @@ class TorrentManager(component.Component): # Could be the clients cache (sessionproxy) isn't up to speed. del status_dict[torrent_id] else: - status_dict[torrent_id] = self.torrents[torrent_id].get_status(torrent_keys, diff) + status_dict[torrent_id] = self.torrents[torrent_id].get_status(torrent_keys, diff, all_keys=not keys) self.status_dict = status_dict d.callback((status_dict, plugin_keys))