mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-13 20:06:23 +00:00
Another attempt to fix #283 .. revamped how resuming/pausing is done
This commit is contained in:
parent
7e7feeb2d8
commit
5934918363
@ -437,7 +437,14 @@ class Torrent:
|
|||||||
"""Pause this torrent"""
|
"""Pause this torrent"""
|
||||||
# Turn off auto-management so the torrent will not be unpaused by lt queueing
|
# Turn off auto-management so the torrent will not be unpaused by lt queueing
|
||||||
self.handle.auto_managed(False)
|
self.handle.auto_managed(False)
|
||||||
|
if self.handle.is_paused():
|
||||||
|
# This torrent was probably paused due to being auto managed by lt
|
||||||
|
# Since we turned auto_managed off, we should update the state which should
|
||||||
|
# show it as 'Paused'. We need to emit a torrent_paused signal because
|
||||||
|
# the torrent_paused alert from libtorrent will not be generated.
|
||||||
|
self.update_state()
|
||||||
|
self.signals.emit("torrent_paused", self.torrent_id)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
self.handle.pause()
|
self.handle.pause()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
@ -448,10 +455,11 @@ class Torrent:
|
|||||||
|
|
||||||
def resume(self):
|
def resume(self):
|
||||||
"""Resumes this torrent"""
|
"""Resumes this torrent"""
|
||||||
# Update the state first just to make sure we have the most current state
|
|
||||||
self.update_state()
|
|
||||||
|
|
||||||
if self.state == "Paused" or self.state == "Error":
|
if self.handle.is_paused() and self.handle.is_auto_managed():
|
||||||
|
log.debug("Torrent is being auto-managed, cannot resume!")
|
||||||
|
return
|
||||||
|
else:
|
||||||
# Reset the status message just in case of resuming an Error'd torrent
|
# Reset the status message just in case of resuming an Error'd torrent
|
||||||
self.set_status_message("OK")
|
self.set_status_message("OK")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user