fix peers tab oops
This commit is contained in:
parent
db11bd01eb
commit
2d9948e083
|
@ -1015,12 +1015,12 @@ class DelugeGTK:
|
|||
dictionary[model.get_value(iter, 1)] = model.get_string_from_iter(iter)
|
||||
|
||||
class remover_data:
|
||||
def __init__(self, new_files):
|
||||
self.new_files = new_files
|
||||
def __init__(self, new_ips):
|
||||
self.new_ips = new_ips
|
||||
self.removed = False
|
||||
|
||||
def remover(model, path, iter, data):
|
||||
if model.get_value(iter, 1) not in data.new_files:
|
||||
if model.get_value(iter, 1) not in data.new_ips:
|
||||
model.remove(iter)
|
||||
data.removed = True
|
||||
return True
|
||||
|
@ -1029,36 +1029,36 @@ class DelugeGTK:
|
|||
|
||||
unique_id = self.get_selected_torrent()
|
||||
|
||||
new_file_info = self.manager.get_torrent_file_info(unique_id)
|
||||
new_peer_info = self.manager.get_torrent_peer_info(unique_id)
|
||||
|
||||
new_files = {}
|
||||
new_ips = {}
|
||||
|
||||
for index in range(len(new_file_info)):
|
||||
if not new_file_info[index]['client'] == "":
|
||||
assert(new_file_info[index]['ip'] not in new_files.keys())
|
||||
new_files[new_file_info[index]['ip']] = index
|
||||
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
|
||||
|
||||
while True:
|
||||
data = remover_data(new_files.keys())
|
||||
data = remover_data(new_ips.keys())
|
||||
self.peer_store.foreach(remover, data)
|
||||
if not data.removed:
|
||||
break
|
||||
|
||||
curr_files = {}
|
||||
curr_ips = {}
|
||||
|
||||
self.peer_store.foreach(biographer, curr_files)
|
||||
self.peer_store.foreach(biographer, curr_ips)
|
||||
|
||||
assert(self.peer_store.iter_n_children(None) == len(curr_files.keys()))
|
||||
assert(self.peer_store.iter_n_children(None) == len(curr_ips.keys()))
|
||||
|
||||
for peer in new_file_info:
|
||||
if peer['ip'] in curr_files.keys():
|
||||
self.peer_store.set(self.peer_store.get_iter_from_string(curr_files[peer['ip']]),
|
||||
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']]),
|
||||
2, unicode(peer['client'], "latin-1"),
|
||||
3, round(peer["peer_has"],2),
|
||||
4, peer["download_speed"],
|
||||
5, peer["upload_speed"])
|
||||
|
||||
if peer['ip'] not in curr_files.keys() and peer['client'] is not "":
|
||||
if peer['ip'] not in curr_ips.keys() and peer['client'] is not "":
|
||||
# convert IP adrress to int for sorting purposes
|
||||
ip_int = sum([int(byte) << shift
|
||||
for byte, shift in izip(peer["ip"].split("."), (24, 16, 8, 0))])
|
||||
|
@ -1069,10 +1069,9 @@ class DelugeGTK:
|
|||
peer["download_speed"],
|
||||
peer["upload_speed"]])
|
||||
|
||||
del new_file_info
|
||||
del new_files
|
||||
del curr_files
|
||||
|
||||
del new_peer_info
|
||||
del new_ips
|
||||
del curr_ips
|
||||
|
||||
elif tab == 2: #file tab
|
||||
|
||||
|
|
Loading…
Reference in New Issue