Implement prioritize first/last pieces
This commit is contained in:
parent
517ba20ae7
commit
cfc742501d
|
@ -141,7 +141,13 @@ class Torrent:
|
|||
self.handle.set_download_limit(int(m_down_speed * 1024))
|
||||
|
||||
def set_prioritize_first_last(self, prioritize):
|
||||
if self.handle.get_torrent_info().num_files() == 1:
|
||||
# We only do this if one file is in the torrent
|
||||
self.prioritize_first_last = prioritize
|
||||
priorities = [1] * self.handle.get_torrent_info().num_pieces()
|
||||
priorities[0] = 7
|
||||
priorities[-1] = 7
|
||||
self.handle.prioritize_pieces(priorities)
|
||||
|
||||
def set_save_path(self, save_path):
|
||||
self.save_path = save_path
|
||||
|
@ -164,6 +170,8 @@ class Torrent:
|
|||
|
||||
self.file_priorities = file_priorities
|
||||
self.handle.prioritize_files(file_priorities)
|
||||
# Set the first/last priorities if needed
|
||||
self.set_prioritize_first_last(self.prioritize_first_last)
|
||||
|
||||
def set_trackers(self, trackers):
|
||||
"""Sets trackers"""
|
||||
|
|
Loading…
Reference in New Issue