Fix #362 use libtorrents session pause/resume instead of current

pause_all, resume_all
This commit is contained in:
Andrew Resch 2008-08-14 06:48:20 +00:00
parent e21183f125
commit 19f9e26a4e
3 changed files with 7 additions and 32 deletions

View File

@ -464,14 +464,12 @@ class Core(
def export_pause_all_torrents(self):
"""Pause all torrents in the session"""
if not self.torrents.pause_all():
log.warning("Error pausing all torrents..")
self.session.pause()
def export_resume_all_torrents(self):
"""Resume all torrents in the session"""
if self.torrents.resume_all():
# Emit the 'torrent_all_resumed' signal
self.torrent_all_resumed()
self.session.resume()
self.torrent_all_resumed()
def export_resume_torrent(self, torrent_ids):
log.debug("Resuming: %s", torrent_ids)

View File

@ -256,7 +256,7 @@ class Torrent:
ltstate = int(self.handle.status().state)
log.debug("set_state_based_on_ltstate: %s", ltstate)
log.debug("session.is_paused: %s", component.get("Core").session.is_paused())
if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]:
self.state = "Checking"
return
@ -272,9 +272,9 @@ class Torrent:
self.state = "Error"
self.set_status_message(self.handle.status().error)
self.handle.auto_managed(False)
elif self.handle.is_paused() and self.handle.is_auto_managed():
elif self.handle.is_paused() and self.handle.is_auto_managed() and not component.get("Core").session.is_paused():
self.state = "Queued"
elif self.handle.is_paused() and not self.handle.is_auto_managed():
elif component.get("Core").session.is_paused() or (self.handle.is_paused() and not self.handle.is_auto_managed()):
self.state = "Paused"
def set_state(self, state):

View File

@ -442,29 +442,6 @@ class TorrentManager(component.Component):
return True
def pause_all(self):
"""Pauses all torrents.. Returns a list of torrents paused."""
torrent_was_paused = False
for key in self.torrents.keys():
try:
self.torrents[key].pause()
torrent_was_paused = True
except:
log.warning("Unable to pause torrent %s", key)
return torrent_was_paused
def resume_all(self):
"""Resumes all torrents.. Returns True if at least 1 torrent is resumed"""
torrent_was_resumed = False
for key in self.torrents.keys():
if self.torrents[key].resume():
torrent_was_resumed = True
else:
log.warning("Unable to resume torrent %s", key)
return torrent_was_resumed
def load_state(self):
"""Load the state of the TorrentManager from the torrents.state file"""
state = TorrentManagerState()