From e1548cc97498dbecac86eb23dc4f35e5a2586a52 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 27 Sep 2015 00:31:20 +0100 Subject: [PATCH] [#1330] [Core] Fix pausing and resuming session * The paused state of torrents is now correctly stored on shutdown if the session is paused. * Resume session refreshes all the torrents' state. This fixes only torrents that changed state being updated so queued torrents would be incorrectly displayed as paused. --- deluge/core/core.py | 2 ++ deluge/core/torrentmanager.py | 7 +++++-- deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index d51a17eb0..c14af338d 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -458,6 +458,8 @@ class Core(component.Component): """Resume all torrents in the session""" if self.session.is_paused(): self.session.resume() + for torrent_id in self.torrentmanager.torrents: + self.torrentmanager[torrent_id].update_state() component.get("EventManager").emit(SessionResumedEvent()) @export diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index e996923c7..f276529ea 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -582,9 +582,12 @@ class TorrentManager(component.Component): state = TorrentManagerState() # Create the state for each Torrent and append to the list for torrent in self.torrents.values(): - paused = False - if torrent.state in ["Paused", "Error"]: + if self.session.is_paused(): + paused = torrent.handle.is_paused() + elif torrent.state in ["Paused", "Error"]: paused = True + else: + paused = False torrent_state = TorrentState( torrent.torrent_id, diff --git a/deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py b/deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py index a69eec7a5..c6e1aa132 100644 --- a/deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py +++ b/deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py @@ -107,7 +107,7 @@ class Core(CorePluginBase): for setting in CONTROLLED_SETTINGS: component.get("PreferencesManager").do_config_set_func(setting, core_config[setting]) # Resume the session if necessary - component.get("Core").session.resume() + component.get("Core").resume_session() def do_schedule(self, timer=True): """