From 1558ab86074cd06ad3fed11fef2001a74b957907 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sun, 13 Apr 2008 04:16:33 +0000 Subject: [PATCH] Fix #85 change torrent state to downloading if changing priority of files in torrent to something other than 'Do Not Download'. --- deluge/core/torrent.py | 10 ++++++++++ deluge/core/torrentmanager.py | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 84e209849..d8ed93828 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -147,6 +147,16 @@ class Torrent: self.save_path = save_path def set_file_priorities(self, file_priorities): + log.debug("setting %s's file priorities: %s", self.torrent_id, file_priorities) + if 0 in self.file_priorities: + # We have previously marked a file 'Do Not Download' + # Check to see if we have changed any 0's to >0 and change state accordingly + for index, priority in enumerate(self.file_priorities): + if priority == 0 and file_priorities[index] > 0: + # We have a changed 'Do Not Download' to a download priority + self.set_state("Downloading") + break + self.file_priorities = file_priorities self.handle.prioritize_files(file_priorities) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 5ac2394e4..9a66f115f 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -602,6 +602,7 @@ class TorrentManager(component.Component): # Get the torrent_id torrent_id = str(alert.handle.info_hash()) log.debug("%s is finished..", torrent_id) + # Queue to bottom if enabled if alert.msg() == "torrent has finished downloading": if self.config["queue_finished_to_bottom"]: @@ -632,7 +633,7 @@ class TorrentManager(component.Component): # Write the fastresume file self.torrents[torrent_id].write_fastresume() - + def on_alert_torrent_checked(self, alert): log.debug("on_alert_torrent_checked") # Get the torrent_id