add index value to directories in file_list

This commit is contained in:
Nick 2011-02-02 12:44:07 +01:00
parent 00fa074452
commit eba7c2bf17
1 changed files with 6 additions and 2 deletions

View File

@ -130,7 +130,8 @@ class TorrentDetail(BaseMode, component.Component):
# particular directory are returned together. it won't work otherwise. # particular directory are returned together. it won't work otherwise.
# returned list is a list of lists of the form: # returned list is a list of lists of the form:
# [file/dir_name,index,size,children,expanded,progress,priority] # [file/dir_name,index,size,children,expanded,progress,priority]
# for directories index will be -1, for files the value returned in the # for directories index values count down from maxint (for marking usage),
# for files the index is the value returned in the
# state object for use with other libtorrent calls (i.e. setting prio) # state object for use with other libtorrent calls (i.e. setting prio)
# #
# Also returns a dictionary that maps index values to the file leaves # Also returns a dictionary that maps index values to the file leaves
@ -138,6 +139,7 @@ class TorrentDetail(BaseMode, component.Component):
def build_file_list(self, file_tuples,prog,prio): def build_file_list(self, file_tuples,prog,prio):
ret = [] ret = []
retdict = {} retdict = {}
diridx = maxint
for f in file_tuples: for f in file_tuples:
cur = ret cur = ret
ps = f["path"].split("/") ps = f["path"].split("/")
@ -151,7 +153,9 @@ class TorrentDetail(BaseMode, component.Component):
format_utils.format_priority(prio[f["index"]])] format_utils.format_priority(prio[f["index"]])]
retdict[f["index"]] = ent retdict[f["index"]] = ent
else: else:
ent = [p,-1,-1,cl,False,"-","-"] ent = [p,diridx,-1,cl,False,"-","-"]
retdict[diridx] = ent
diridx-=1
cur.append(ent) cur.append(ent)
cur = cl cur = cl
else: else: