From 944dc1659f9f346dd78ff1cf8c0b9367a80222cb Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Mon, 24 Sep 2018 15:07:58 +0100 Subject: [PATCH] [Core] Fix UI file priorities out-of-sync with libtorrent The file priorities were not updating correctly in the UI and it was found that in lt 1.1 file priorities are now updated asynchonously so we cannot get the values immediately. So only update the options file_priorities if they are empty. --- deluge/core/torrent.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 00e66f662..2a834c773 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -503,7 +503,9 @@ class Torrent(object): log.debug('Unable to set new file priorities.') file_priorities = self.handle.file_priorities() - if 0 in self.options['file_priorities']: + if not self.options['file_priorities']: + self.options['file_priorities'] = file_priorities + elif 0 in self.options['file_priorities']: # Previously marked a file 'Do Not Download' so check if changed any 0's to >0. for index, priority in enumerate(self.options['file_priorities']): if priority == 0 and file_priorities[index] > 0: @@ -512,9 +514,6 @@ class Torrent(object): self.update_state() break - # Ensure stored options are in sync in case file_priorities were faulty (old state?). - self.options['file_priorities'] = self.handle.file_priorities() - # Set the first/last priorities if needed. if self.options['prioritize_first_last_pieces']: self.set_prioritize_first_last_pieces(self.options['prioritize_first_last_pieces'])