Fix bug in prioritize_first_last, also fixes selective downloading. refs #2211
This commit is contained in:
parent
8298a93dcc
commit
9d28aa9521
|
@ -315,14 +315,14 @@ class Torrent(object):
|
||||||
for n in range(ti.num_pieces()):
|
for n in range(ti.num_pieces()):
|
||||||
slices = ti.map_block(n, 0, ti.piece_size(n))
|
slices = ti.map_block(n, 0, ti.piece_size(n))
|
||||||
for slice in slices:
|
for slice in slices:
|
||||||
fe = ti.file_at(slice.file_index)
|
if self.handle.file_priority(slice.file_index):
|
||||||
paths.setdefault(fe.path, []).append(n)
|
paths.setdefault(slice.file_index, []).append(n)
|
||||||
|
|
||||||
priorities = self.handle.piece_priorities()
|
priorities = self.handle.piece_priorities()
|
||||||
for pieces in paths.itervalues():
|
for pieces in paths.itervalues():
|
||||||
two_percent = 2*100/len(pieces)
|
two_percent = int(0.02*len(pieces)) or 1
|
||||||
for piece in pieces[:two_percent]+pieces[-two_percent:]:
|
for piece in pieces[:two_percent]+pieces[-two_percent:]:
|
||||||
priorities[piece] = prioritize and 7 or 1
|
priorities[piece] = 7 if prioritize else 1
|
||||||
self.handle.prioritize_pieces(priorities)
|
self.handle.prioritize_pieces(priorities)
|
||||||
|
|
||||||
def set_sequential_download(self, set_sequencial):
|
def set_sequential_download(self, set_sequencial):
|
||||||
|
|
Loading…
Reference in New Issue