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,13 +464,11 @@ class Core(
def export_pause_all_torrents(self): def export_pause_all_torrents(self):
"""Pause all torrents in the session""" """Pause all torrents in the session"""
if not self.torrents.pause_all(): self.session.pause()
log.warning("Error pausing all torrents..")
def export_resume_all_torrents(self): def export_resume_all_torrents(self):
"""Resume all torrents in the session""" """Resume all torrents in the session"""
if self.torrents.resume_all(): self.session.resume()
# Emit the 'torrent_all_resumed' signal
self.torrent_all_resumed() self.torrent_all_resumed()
def export_resume_torrent(self, torrent_ids): def export_resume_torrent(self, torrent_ids):

View File

@ -256,7 +256,7 @@ class Torrent:
ltstate = int(self.handle.status().state) ltstate = int(self.handle.status().state)
log.debug("set_state_based_on_ltstate: %s", ltstate) 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"]: if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]:
self.state = "Checking" self.state = "Checking"
return return
@ -272,9 +272,9 @@ class Torrent:
self.state = "Error" self.state = "Error"
self.set_status_message(self.handle.status().error) self.set_status_message(self.handle.status().error)
self.handle.auto_managed(False) 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" 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" self.state = "Paused"
def set_state(self, state): def set_state(self, state):

View File

@ -442,29 +442,6 @@ class TorrentManager(component.Component):
return True 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): def load_state(self):
"""Load the state of the TorrentManager from the torrents.state file""" """Load the state of the TorrentManager from the torrents.state file"""
state = TorrentManagerState() state = TorrentManagerState()