mirror of
https://git.deluge-torrent.org/deluge
synced 2025-09-26 20:28:32 +00:00
Fix #2006 : Display error when moving storage location fails
Adds handler for storage_moved_failed_alert and then sets the torrent to Error state and pauses it.
This commit is contained in:
parent
35842af019
commit
a2fcaa15c9
2 changed files with 21 additions and 4 deletions
|
@ -182,11 +182,11 @@ class Torrent(object):
|
||||||
# Various torrent options
|
# Various torrent options
|
||||||
self.handle.resolve_countries(True)
|
self.handle.resolve_countries(True)
|
||||||
|
|
||||||
self.set_options(self.options)
|
|
||||||
|
|
||||||
# Status message holds error info about the torrent
|
# Status message holds error info about the torrent
|
||||||
self.statusmsg = "OK"
|
self.statusmsg = "OK"
|
||||||
|
|
||||||
|
self.set_options(self.options)
|
||||||
|
|
||||||
# The torrent's state
|
# The torrent's state
|
||||||
self.state = None
|
self.state = None
|
||||||
|
|
||||||
|
@ -452,8 +452,7 @@ class Torrent(object):
|
||||||
log.debug("set_state_based_on_ltstate: %s", deluge.common.LT_TORRENT_STATE[ltstate])
|
log.debug("set_state_based_on_ltstate: %s", deluge.common.LT_TORRENT_STATE[ltstate])
|
||||||
log.debug("session.is_paused: %s", session_is_paused)
|
log.debug("session.is_paused: %s", session_is_paused)
|
||||||
|
|
||||||
# First we check for an error from libtorrent, and set the state to that
|
# First we check for an error from libtorrent, and set the state to that if any occurred.
|
||||||
# if any occurred.
|
|
||||||
if len(status.error) > 0:
|
if len(status.error) > 0:
|
||||||
# This is an error'd torrent
|
# This is an error'd torrent
|
||||||
self.state = "Error"
|
self.state = "Error"
|
||||||
|
@ -461,6 +460,11 @@ class Torrent(object):
|
||||||
if status.paused:
|
if status.paused:
|
||||||
self.handle.auto_managed(False)
|
self.handle.auto_managed(False)
|
||||||
return
|
return
|
||||||
|
elif self.statusmsg.startswith("Error:"):
|
||||||
|
self.state = "Error"
|
||||||
|
if status.paused:
|
||||||
|
self.handle.auto_managed(False)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
self.set_status_message("OK")
|
self.set_status_message("OK")
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,7 @@ class TorrentManager(component.Component):
|
||||||
self.alerts.register_handler("tracker_warning_alert", self.on_alert_tracker_warning)
|
self.alerts.register_handler("tracker_warning_alert", self.on_alert_tracker_warning)
|
||||||
self.alerts.register_handler("tracker_error_alert", self.on_alert_tracker_error)
|
self.alerts.register_handler("tracker_error_alert", self.on_alert_tracker_error)
|
||||||
self.alerts.register_handler("storage_moved_alert", self.on_alert_storage_moved)
|
self.alerts.register_handler("storage_moved_alert", self.on_alert_storage_moved)
|
||||||
|
self.alerts.register_handler("storage_moved_failed_alert", self.on_alert_storage_moved_failed)
|
||||||
self.alerts.register_handler("torrent_resumed_alert", self.on_alert_torrent_resumed)
|
self.alerts.register_handler("torrent_resumed_alert", self.on_alert_torrent_resumed)
|
||||||
self.alerts.register_handler("state_changed_alert", self.on_alert_state_changed)
|
self.alerts.register_handler("state_changed_alert", self.on_alert_state_changed)
|
||||||
self.alerts.register_handler("save_resume_data_alert", self.on_alert_save_resume_data)
|
self.alerts.register_handler("save_resume_data_alert", self.on_alert_save_resume_data)
|
||||||
|
@ -1028,6 +1029,18 @@ class TorrentManager(component.Component):
|
||||||
torrent.set_save_path(os.path.normpath(alert.handle.save_path()))
|
torrent.set_save_path(os.path.normpath(alert.handle.save_path()))
|
||||||
torrent.set_move_completed(False)
|
torrent.set_move_completed(False)
|
||||||
|
|
||||||
|
def on_alert_storage_moved_failed(self, alert):
|
||||||
|
"""Alert handler for libtorrent storage_moved_failed_alert"""
|
||||||
|
log.warning("on_alert_storage_moved_failed: %s", decode_string(alert.message()))
|
||||||
|
try:
|
||||||
|
torrent_id = str(alert.handle.info_hash())
|
||||||
|
torrent = self.torrents[torrent_id]
|
||||||
|
except (RuntimeError, KeyError):
|
||||||
|
return
|
||||||
|
# Set an Error message and pause the torrent
|
||||||
|
torrent.set_status_message("Error: moving storage location failed")
|
||||||
|
torrent.pause()
|
||||||
|
|
||||||
def on_alert_torrent_resumed(self, alert):
|
def on_alert_torrent_resumed(self, alert):
|
||||||
"""Alert handler for libtorrent torrent_resumed_alert"""
|
"""Alert handler for libtorrent torrent_resumed_alert"""
|
||||||
log.debug("on_alert_torrent_resumed")
|
log.debug("on_alert_torrent_resumed")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue