Keep a torrent paused after a forced recheck if it was paused to start.

This commit is contained in:
Andrew Resch 2010-10-10 12:34:13 -07:00
parent 59e01e7ecf
commit 60fac28217
2 changed files with 16 additions and 1 deletions

View File

@ -179,6 +179,11 @@ class Torrent(object):
else: else:
self.time_added = time.time() self.time_added = time.time()
# 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.") log.debug("Torrent object created.")
## Options methods ## ## Options methods ##
@ -859,12 +864,15 @@ class Torrent(object):
def force_recheck(self): def force_recheck(self):
"""Forces a recheck of the torrents pieces""" """Forces a recheck of the torrents pieces"""
paused = self.handle.is_paused()
try: try:
self.handle.force_recheck() self.handle.force_recheck()
self.handle.resume() self.handle.resume()
except Exception, e: except Exception, e:
log.debug("Unable to force recheck: %s", e) log.debug("Unable to force recheck: %s", e)
return False return False
self.forcing_recheck = True
self.forcing_recheck_paused = paused
return True return True
def rename_files(self, filenames): def rename_files(self, filenames):

View File

@ -850,6 +850,13 @@ class TorrentManager(component.Component):
except: except:
return 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 # Set the torrent state
torrent.update_state() torrent.update_state()