From 19f9e26a4e64dfd6a863635e426e2a1ac32b3a9a Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Thu, 14 Aug 2008 06:48:20 +0000 Subject: [PATCH] Fix #362 use libtorrents session pause/resume instead of current pause_all, resume_all --- deluge/core/core.py | 8 +++----- deluge/core/torrent.py | 6 +++--- deluge/core/torrentmanager.py | 25 +------------------------ 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index 88c0b99f5..9d0eded00 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -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) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 2f5698c8f..e9debeadf 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -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): diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 8571c4573..a44cd5cdc 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -441,30 +441,7 @@ class TorrentManager(component.Component): self.signals.emit("torrent_removed", torrent_id) 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()