diff --git a/deluge/core/core.py b/deluge/core/core.py index b5ceca53b..eb158f8a3 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -409,15 +409,18 @@ class Core(component.Component): @export def pause_all_torrents(self): """Pause all torrents in the session""" - for torrent in self.torrentmanager.torrents.values(): - torrent.pause() + if not self.session.is_paused(): + self.session.pause() + component.get("EventManager").emit(SessionPausedEvent()) @export def resume_all_torrents(self): """Resume all torrents in the session""" - for torrent in self.torrentmanager.torrents.values(): - torrent.resume() - component.get("EventManager").emit(SessionResumedEvent()) + if self.session.is_paused(): + self.session.resume() + for torrent in self.torrentmanager.torrents.values(): + torrent.update_state() + component.get("EventManager").emit(SessionResumedEvent()) @export def resume_torrent(self, torrent_ids): diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 31d926303..8287bb9b1 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -674,9 +674,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 == "Paused": + if self.session.is_paused(): + paused = torrent.handle.is_paused() + elif torrent.state == "Paused": paused = True + else: + paused = False torrent_state = TorrentState( torrent.torrent_id, diff --git a/deluge/plugins/blocklist/blocklist/core.py b/deluge/plugins/blocklist/blocklist/core.py index 12cee457f..39ac72db1 100644 --- a/deluge/plugins/blocklist/blocklist/core.py +++ b/deluge/plugins/blocklist/blocklist/core.py @@ -425,12 +425,12 @@ class Core(CorePluginBase): def pause_session(self): if not self.core.session.is_paused(): - self.core.session.pause() + self.core.pause_all_torrents() self.need_to_resume_session = True else: self.need_to_resume_session = False def resume_session(self, result): - self.core.session.resume() + self.core.resume_all_torrents() self.need_to_resume_session = False return result diff --git a/deluge/plugins/scheduler/scheduler/core.py b/deluge/plugins/scheduler/scheduler/core.py index f0e23923f..bb63e9d01 100644 --- a/deluge/plugins/scheduler/scheduler/core.py +++ b/deluge/plugins/scheduler/scheduler/core.py @@ -129,7 +129,7 @@ class Core(CorePluginBase): for setting in CONTROLLED_SETTINGS: core_config.apply_set_functions(setting) # Resume the session if necessary - component.get("Core").session.resume() + component.get("Core").resume_all_torrents() def do_schedule(self, timer=True): """ @@ -153,10 +153,10 @@ class Core(CorePluginBase): settings.active_seeds = self.config["low_active_up"] session.set_settings(settings) # Resume the session if necessary - component.get("Core").session.resume() + component.get("Core").resume_all_torrents() elif state == "Red": # This is Red (Stop), so pause the libtorrent session - component.get("Core").session.pause() + component.get("Core").pause_all_torrents() if state != self.state: # The state has changed since last update so we need to emit an event