mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-12 11:20:09 +00:00
Another attempt to fix #283 .. revamped how resuming/pausing is done
This commit is contained in:
parent
7e7feeb2d8
commit
5934918363
1 changed files with 18 additions and 10 deletions
|
@ -437,21 +437,29 @@ 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():
|
||||||
try:
|
# This torrent was probably paused due to being auto managed by lt
|
||||||
self.handle.pause()
|
# Since we turned auto_managed off, we should update the state which should
|
||||||
except Exception, e:
|
# show it as 'Paused'. We need to emit a torrent_paused signal because
|
||||||
log.debug("Unable to pause torrent: %s", e)
|
# the torrent_paused alert from libtorrent will not be generated.
|
||||||
return False
|
self.update_state()
|
||||||
|
self.signals.emit("torrent_paused", self.torrent_id)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self.handle.pause()
|
||||||
|
except Exception, e:
|
||||||
|
log.debug("Unable to pause torrent: %s", e)
|
||||||
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
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…
Add table
Add a link
Reference in a new issue