partial fix for peer_view bug
This commit is contained in:
parent
effeb72b31
commit
c8f701b551
|
@ -379,6 +379,9 @@ class DelugeGTK(dbus.service.Object):
|
||||||
self.store.remove(itr)
|
self.store.remove(itr)
|
||||||
if not self.store.iter_is_valid(itr):
|
if not self.store.iter_is_valid(itr):
|
||||||
itr = None
|
itr = None
|
||||||
|
|
||||||
|
self.saved_peer_info = None
|
||||||
|
|
||||||
if tab == 0: #Details Pane
|
if tab == 0: #Details Pane
|
||||||
try:
|
try:
|
||||||
state = self.manager.get_torrent_state(self.get_selected_torrent())
|
state = self.manager.get_torrent_state(self.get_selected_torrent())
|
||||||
|
@ -404,13 +407,62 @@ class DelugeGTK(dbus.service.Object):
|
||||||
#self.text_summary_compact_allocation.set_text(str(state[""]))
|
#self.text_summary_compact_allocation.set_text(str(state[""]))
|
||||||
self.text_summary_eta.set_text(dcommon.estimate_eta(state))
|
self.text_summary_eta.set_text(dcommon.estimate_eta(state))
|
||||||
elif tab == 1: #Peers List
|
elif tab == 1: #Peers List
|
||||||
uid = self.get_selected_torrent()
|
unique_id = self.get_selected_torrent()
|
||||||
self.peer_store.clear()
|
|
||||||
peer_data = self.manager.get_torrent_peer_info(uid)
|
if self.saved_peer_info is None:
|
||||||
for peer in peer_data:
|
self.saved_peer_info = self.manager.get_torrent_peer_info(unique_id)
|
||||||
# ip client percent dl ul
|
|
||||||
|
|
||||||
|
new_peer_info = self.saved_peer_info
|
||||||
|
|
||||||
|
new_ips = {}
|
||||||
|
|
||||||
|
for index in range(len(new_peer_info)):
|
||||||
|
if not new_peer_info[index]['client'] == "":
|
||||||
|
assert(new_peer_info[index]['ip'] not in new_ips.keys())
|
||||||
|
new_ips[new_peer_info[index]['ip']] = index
|
||||||
|
|
||||||
|
def biographer(model, path, iter, dictionary):
|
||||||
|
assert(model.get_value(iter, 0) not in dictionary.keys())
|
||||||
|
dictionary[model.get_value(iter, 0)] = model.get_string_from_iter(iter)
|
||||||
|
|
||||||
|
class remover_data:
|
||||||
|
def __init__(self, new_ips):
|
||||||
|
self.new_ips = new_ips
|
||||||
|
self.removed = False
|
||||||
|
|
||||||
|
def remover(model, path, iter, data):
|
||||||
|
if model.get_value(iter, 0) not in data.new_ips:
|
||||||
|
model.remove(iter)
|
||||||
|
data.removed = True
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
while True:
|
||||||
|
data = remover_data(new_ips.keys())
|
||||||
|
self.peer_store.foreach(remover, data)
|
||||||
|
if not data.removed:
|
||||||
|
break
|
||||||
|
|
||||||
|
curr_ips = {}
|
||||||
|
|
||||||
|
self.peer_store.foreach(biographer, curr_ips)
|
||||||
|
|
||||||
|
assert(self.peer_store.iter_n_children(None) == len(curr_ips.keys()))
|
||||||
|
|
||||||
|
for peer in new_peer_info:
|
||||||
|
if peer['ip'] in curr_ips.keys():
|
||||||
|
self.peer_store.set(self.peer_store.get_iter_from_string(curr_ips[peer['ip']]),
|
||||||
|
1, unicode(peer['client'], 'Latin-1'),
|
||||||
|
2, peer['peer_has'],
|
||||||
|
3, peer['download_speed'],
|
||||||
|
4, peer['upload_speed'])
|
||||||
|
for peer in new_peer_info:
|
||||||
|
if peer['ip'] not in curr_ips.keys() and peer['client'] is not "":
|
||||||
self.peer_store.append([peer["ip"], unicode(peer["client"], 'Latin-1'), peer["peer_has"],
|
self.peer_store.append([peer["ip"], unicode(peer["client"], 'Latin-1'), peer["peer_has"],
|
||||||
peer["download_speed"], peer["upload_speed"]])
|
peer["download_speed"], peer["upload_speed"]])
|
||||||
|
|
||||||
elif tab == 2: #File List
|
elif tab == 2: #File List
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue