From ea7fdc3bc13bf0bc24c0a95695a1f7b5429ef703 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sat, 29 Dec 2007 01:39:58 +0000 Subject: [PATCH] tweak pause/resume --- src/core.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/core.py b/src/core.py index 4366de011..433e574a7 100644 --- a/src/core.py +++ b/src/core.py @@ -758,19 +758,23 @@ Space:") + " " + nice_free) deluge_core.scrape_tracker(unique_ID) def pause(self, unique_ID): - try: - deluge_core.pause(unique_ID) - except: - print "pause failed\n" + state = self.get_torrent_state(unique_ID) + if not state["is_paused"]: + try: + deluge_core.pause(unique_ID) + except: + print "pause failed\n" def resume(self, unique_ID): - try: - deluge_core.resume(unique_ID) - # We have to re-apply per torrent settings after resume. This has to - # be done until ticket #118 in libtorrent is fixed. - self.apply_prefs_per_torrent(unique_ID) - except: - print "pause failed\n" + state = self.get_torrent_state(unique_ID) + if state["is_paused"]: + try: + deluge_core.resume(unique_ID) + # We have to re-apply per torrent settings after resume. This has to + # be done until ticket #118 in libtorrent is fixed. + self.apply_prefs_per_torrent(unique_ID) + except: + print "pause failed\n" def pause_all(self): if self.config.get('max_active_torrents') != 0: @@ -884,7 +888,6 @@ Space:") + " " + nice_free) except DelugeError, e: del self.state.torrents[torrent] raise e - ret = unique_ID self.unique_IDs[unique_ID] = torrent self.state.torrents[torrent] = unique_ID