Fix #2277 : Plugins keys weren't fetched in filter_torrent_ids

Fixed bug introduced in 8c106ce8c4
where keys for plugins weren't fetched in filter_torrent_ids.
This commit is contained in:
bendikro 2013-02-15 11:38:14 +01:00 committed by Calum Lind
parent 4b31061037
commit e6498b6864
4 changed files with 9 additions and 8 deletions

View File

@ -420,9 +420,9 @@ class Core(component.Component):
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
self.torrentmanager[torrent_id].resume() 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: 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: except KeyError:
import traceback import traceback
traceback.print_exc() traceback.print_exc()
@ -437,7 +437,7 @@ class Core(component.Component):
@export @export
def get_torrent_status(self, torrent_id, keys, diff=False): def get_torrent_status(self, torrent_id, keys, diff=False):
torrent_keys, plugin_keys = self.torrentmanager.separate_keys(keys, [torrent_id]) 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 @export
def get_torrents_status(self, filter_dict, keys, diff=False): def get_torrents_status(self, filter_dict, keys, diff=False):

View File

@ -189,10 +189,11 @@ class FilterManager(component.Component):
if not filter_dict: #return if there's nothing more to filter if not filter_dict: #return if there's nothing more to filter
return torrent_ids return torrent_ids
torrent_keys, plugin_keys = self.torrents.separate_keys(filter_dict.keys(), torrent_ids)
#leftover filter arguments: #leftover filter arguments:
#default filter on status fields. #default filter on status fields.
for torrent_id in list(torrent_ids): 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(): for field, values in filter_dict.iteritems():
if (not status[field] in values) and torrent_id in torrent_ids: if (not status[field] in values) and torrent_id in torrent_ids:
torrent_ids.remove(torrent_id) torrent_ids.remove(torrent_id)

View File

@ -626,7 +626,7 @@ class Torrent(object):
return host return host
return "" 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 Returns the status of the torrent based on the keys provided
@ -646,7 +646,7 @@ class Torrent(object):
if update: if update:
self.update_status(self.handle.status()) self.update_status(self.handle.status())
if not keys: if all_keys:
keys = self.status_funcs.keys() keys = self.status_funcs.keys()
status_dict = {} status_dict = {}

View File

@ -1151,7 +1151,7 @@ class TorrentManager(component.Component):
# Could be the clients cache (sessionproxy) isn't up to speed. # Could be the clients cache (sessionproxy) isn't up to speed.
del status_dict[torrent_id] del status_dict[torrent_id]
else: 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 self.status_dict = status_dict
d.callback((status_dict, plugin_keys)) d.callback((status_dict, plugin_keys))