Changeset 78851b


Ignore:
Timestamp:
01/17/2017 09:20:11 AM (8 years ago)
Author:
Calum Lind <calumlind+deluge@gmail.com>
Children:
bd80ad
Parents:
af76ab
git-author:
Calum Lind <calumlind+deluge@gmail.com> (01/11/2017 12:58:15 PM)
git-committer:
Calum Lind <calumlind+deluge@gmail.com> (01/17/2017 09:20:11 AM)
Message:

#2946 Workaround 1.1 libtorrent default piece priority

  • The default piece priority was changed in lt 1.1 from 1 to 4 so in 1.3 we will simple convert them back to 1 as 4 is not used.
  • The set_file_priorities method was refactored to make the changes simpler.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • deluge/core/torrent.py

    raf76ab r78851b  
    311311
    312312    def set_file_priorities(self, file_priorities):
    313         if len(file_priorities) != len(self.get_files()):
    314             log.debug("file_priorities len != num_files")
    315             self.options["file_priorities"] = self.handle.file_priorities()
    316             return
    317 
    318         if self.options["compact_allocation"]:
    319             log.debug("setting file priority with compact allocation does not work!")
    320             self.options["file_priorities"] = self.handle.file_priorities()
    321             return
     313        handle_file_priorities = self.handle.file_priorities()
     314        # Workaround for libtorrent 1.1 changing default priorities from 1 to 4.
     315        if 4 in handle_file_priorities:
     316           handle_file_priorities = [1 if x == 4 else x for x in handle_file_priorities]
    322317
    323318        log.debug("setting %s's file priorities: %s", self.torrent_id, file_priorities)
    324319
    325         self.handle.prioritize_files(file_priorities)
     320        if (self.handle.has_metadata() and not self.options["compact_allocation"] and
     321                file_priorities and len(file_priorities) == len(self.get_files())):
     322            self.handle.prioritize_files(file_priorities)
     323        else:
     324            log.debug("Unable to set new file priorities.")
     325            file_priorities = handle_file_priorities
    326326
    327327        if 0 in self.options["file_priorities"]:
     
    335335                    break
    336336
    337         self.options["file_priorities"] = self.handle.file_priorities()
     337        self.options["file_priorities"] = handle_file_priorities
    338338        if self.options["file_priorities"] != list(file_priorities):
    339339            log.warning("File priorities were not set for this torrent")
Note: See TracChangeset for help on using the changeset viewer.