mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 15:38:43 +00:00
[#1032] Keep track of torrent errors over restarts
This commit is contained in:
parent
ddde10ec99
commit
2c54c696a1
2 changed files with 28 additions and 4 deletions
|
@ -169,6 +169,11 @@ class Torrent(object):
|
||||||
# Set the filename
|
# Set the filename
|
||||||
self.filename = state.filename
|
self.filename = state.filename
|
||||||
self.is_finished = state.is_finished
|
self.is_finished = state.is_finished
|
||||||
|
last_sess_prepend = "[Error from Previous Session] "
|
||||||
|
if state.error_statusmsg and not state.error_statusmsg.startswith(last_sess_prepend):
|
||||||
|
self.error_statusmsg = last_sess_prepend + state.error_statusmsg
|
||||||
|
else:
|
||||||
|
self.error_statusmsg = state.error_statusmsg
|
||||||
else:
|
else:
|
||||||
# Tracker list
|
# Tracker list
|
||||||
self.trackers = []
|
self.trackers = []
|
||||||
|
@ -181,6 +186,7 @@ class Torrent(object):
|
||||||
else:
|
else:
|
||||||
tracker = value
|
tracker = value
|
||||||
self.trackers.append(tracker)
|
self.trackers.append(tracker)
|
||||||
|
self.error_statusmsg = None
|
||||||
|
|
||||||
# Various torrent options
|
# Various torrent options
|
||||||
self.handle.resolve_countries(True)
|
self.handle.resolve_countries(True)
|
||||||
|
@ -383,13 +389,26 @@ class Torrent(object):
|
||||||
|
|
||||||
# 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(self.handle.status().error) > 0:
|
status_error = self.handle.status().error
|
||||||
|
if status_error or self.error_statusmsg:
|
||||||
# This is an error'd torrent
|
# This is an error'd torrent
|
||||||
self.state = "Error"
|
self.state = "Error"
|
||||||
self.set_status_message(self.handle.status().error)
|
if status_error:
|
||||||
|
self.error_statusmsg = status_error
|
||||||
|
self.set_status_message(self.error_statusmsg)
|
||||||
|
|
||||||
if self.handle.is_paused():
|
if self.handle.is_paused():
|
||||||
self.handle.auto_managed(False)
|
self.handle.auto_managed(False)
|
||||||
|
else:
|
||||||
|
self.handle.pause()
|
||||||
|
|
||||||
|
if not status_error:
|
||||||
|
# As this is not a libtorrent Error we should emit a state changed event
|
||||||
|
component.get("EventManager").emit(TorrentStateChangedEvent(self.torrent_id, "Error"))
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
self.set_status_message("OK")
|
||||||
|
self.error_statusmsg = None
|
||||||
|
|
||||||
if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]:
|
if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]:
|
||||||
if self.handle.is_paused():
|
if self.handle.is_paused():
|
||||||
|
@ -803,6 +822,7 @@ class Torrent(object):
|
||||||
else:
|
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")
|
||||||
|
self.error_statusmsg = None
|
||||||
|
|
||||||
if self.handle.is_finished():
|
if self.handle.is_finished():
|
||||||
# If the torrent has already reached it's 'stop_seed_ratio' then do not do anything
|
# If the torrent has already reached it's 'stop_seed_ratio' then do not do anything
|
||||||
|
|
|
@ -77,6 +77,7 @@ class TorrentState:
|
||||||
queue=None,
|
queue=None,
|
||||||
auto_managed=True,
|
auto_managed=True,
|
||||||
is_finished=False,
|
is_finished=False,
|
||||||
|
error_statusmsg=None,
|
||||||
stop_ratio=2.00,
|
stop_ratio=2.00,
|
||||||
stop_at_ratio=False,
|
stop_at_ratio=False,
|
||||||
remove_at_ratio=False,
|
remove_at_ratio=False,
|
||||||
|
@ -91,6 +92,7 @@ class TorrentState:
|
||||||
self.trackers = trackers
|
self.trackers = trackers
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
self.is_finished = is_finished
|
self.is_finished = is_finished
|
||||||
|
self.error_statusmsg = error_statusmsg
|
||||||
self.magnet = magnet
|
self.magnet = magnet
|
||||||
self.time_added = time_added
|
self.time_added = time_added
|
||||||
|
|
||||||
|
@ -111,6 +113,7 @@ class TorrentState:
|
||||||
self.move_completed = move_completed
|
self.move_completed = move_completed
|
||||||
self.move_completed_path = move_completed_path
|
self.move_completed_path = move_completed_path
|
||||||
|
|
||||||
|
|
||||||
class TorrentManagerState:
|
class TorrentManagerState:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.torrents = []
|
self.torrents = []
|
||||||
|
@ -672,7 +675,7 @@ class TorrentManager(component.Component):
|
||||||
# Create the state for each Torrent and append to the list
|
# Create the state for each Torrent and append to the list
|
||||||
for torrent in self.torrents.values():
|
for torrent in self.torrents.values():
|
||||||
paused = False
|
paused = False
|
||||||
if torrent.state == "Paused":
|
if torrent.state in ["Paused", "Error"]:
|
||||||
paused = True
|
paused = True
|
||||||
|
|
||||||
torrent_state = TorrentState(
|
torrent_state = TorrentState(
|
||||||
|
@ -692,6 +695,7 @@ class TorrentManager(component.Component):
|
||||||
torrent.get_queue_position(),
|
torrent.get_queue_position(),
|
||||||
torrent.options["auto_managed"],
|
torrent.options["auto_managed"],
|
||||||
torrent.is_finished,
|
torrent.is_finished,
|
||||||
|
torrent.error_statusmsg,
|
||||||
torrent.options["stop_ratio"],
|
torrent.options["stop_ratio"],
|
||||||
torrent.options["stop_at_ratio"],
|
torrent.options["stop_at_ratio"],
|
||||||
torrent.options["remove_at_ratio"],
|
torrent.options["remove_at_ratio"],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue