From 9d28aa9521ee4e6f424b6cd5dc694a15a0e394ae Mon Sep 17 00:00:00 2001 From: Chase Sterling Date: Tue, 13 Nov 2012 01:36:04 -0500 Subject: [PATCH] Fix bug in prioritize_first_last, also fixes selective downloading. refs #2211 --- deluge/core/torrent.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index d244be610..cafec162c 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -315,14 +315,14 @@ class Torrent(object): for n in range(ti.num_pieces()): slices = ti.map_block(n, 0, ti.piece_size(n)) for slice in slices: - fe = ti.file_at(slice.file_index) - paths.setdefault(fe.path, []).append(n) + if self.handle.file_priority(slice.file_index): + paths.setdefault(slice.file_index, []).append(n) priorities = self.handle.piece_priorities() 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:]: - priorities[piece] = prioritize and 7 or 1 + priorities[piece] = 7 if prioritize else 1 self.handle.prioritize_pieces(priorities) def set_sequential_download(self, set_sequencial):