From a827cf6c7aa28023b5fd6aed020983d8db9e1974 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sun, 10 Oct 2010 12:34:13 -0700 Subject: [PATCH] Keep a torrent paused after a forced recheck if it was paused to start. --- deluge/core/torrent.py | 8 ++++++++ deluge/core/torrentmanager.py | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 74c888579..3b613356a 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -186,6 +186,11 @@ class Torrent(object): else: self.owner = owner + # Keep track if we're forcing a recheck of the torrent so that we can + # repause it after its done if necessary + self.forcing_recheck = False + self.forcing_recheck_paused = False + log.debug("Torrent object created.") ## Options methods ## @@ -871,12 +876,15 @@ class Torrent(object): def force_recheck(self): """Forces a recheck of the torrents pieces""" + paused = self.handle.is_paused() try: self.handle.force_recheck() self.handle.resume() except Exception, e: log.debug("Unable to force recheck: %s", e) return False + self.forcing_recheck = True + self.forcing_recheck_paused = paused return True def rename_files(self, filenames): diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index fcf18603b..93f0a9794 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -857,7 +857,14 @@ class TorrentManager(component.Component): torrent = self.torrents[str(alert.handle.info_hash())] except: return - + + # Check to see if we're forcing a recheck and set it back to paused + # if necessary + if torrent.forcing_recheck: + torrent.forcing_recheck = False + if torrent.forcing_recheck_paused: + torrent.handle.pause() + # Set the torrent state torrent.update_state()