mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 15:08:40 +00:00
[Core] Add fastresume rejected alert handler
This commit is contained in:
parent
86b1b75fb8
commit
34e92b9f12
1 changed files with 27 additions and 0 deletions
|
@ -202,6 +202,8 @@ class TorrentManager(component.Component):
|
||||||
self.on_alert_file_error)
|
self.on_alert_file_error)
|
||||||
self.alerts.register_handler("file_completed_alert",
|
self.alerts.register_handler("file_completed_alert",
|
||||||
self.on_alert_file_completed)
|
self.on_alert_file_completed)
|
||||||
|
self.alerts.register_handler("fastresume_rejected_alert",
|
||||||
|
self.on_alert_fastresume_rejected)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
# Get the pluginmanager reference
|
# Get the pluginmanager reference
|
||||||
|
@ -491,6 +493,10 @@ class TorrentManager(component.Component):
|
||||||
|
|
||||||
component.resume("AlertManager")
|
component.resume("AlertManager")
|
||||||
|
|
||||||
|
# Store the orignal resume_data, in case of errors.
|
||||||
|
if resume_data:
|
||||||
|
self.resume_data[torrent.torrent_id] = resume_data
|
||||||
|
|
||||||
# Resume the torrent if needed
|
# Resume the torrent if needed
|
||||||
if not options["add_paused"]:
|
if not options["add_paused"]:
|
||||||
torrent.resume()
|
torrent.resume()
|
||||||
|
@ -1123,6 +1129,27 @@ class TorrentManager(component.Component):
|
||||||
|
|
||||||
self.save_resume_data_file()
|
self.save_resume_data_file()
|
||||||
|
|
||||||
|
def on_alert_fastresume_rejected(self, alert):
|
||||||
|
"""Alert handler for libtorrent fastresume_rejected_alert"""
|
||||||
|
alert_msg = decode_string(alert.message())
|
||||||
|
log.error("on_alert_fastresume_rejected: %s", alert_msg)
|
||||||
|
try:
|
||||||
|
torrent_id = str(alert.handle.info_hash())
|
||||||
|
torrent = self.torrents[torrent_id]
|
||||||
|
except (RuntimeError, KeyError):
|
||||||
|
return
|
||||||
|
|
||||||
|
if alert.error.value() == 134:
|
||||||
|
if not os.path.isdir(torrent.options["download_location"]):
|
||||||
|
error_msg = "Unable to locate Download Folder!"
|
||||||
|
else:
|
||||||
|
error_msg = "Missing or invalid torrent data!"
|
||||||
|
else:
|
||||||
|
error_msg = "Problem with resume data: %s" % alert_msg.split(":", 1)[1].strip()
|
||||||
|
|
||||||
|
torrent.set_status_message("Error: " + error_msg)
|
||||||
|
torrent.pause()
|
||||||
|
torrent.update_state()
|
||||||
|
|
||||||
def on_alert_file_renamed(self, alert):
|
def on_alert_file_renamed(self, alert):
|
||||||
log.debug("on_alert_file_renamed")
|
log.debug("on_alert_file_renamed")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue