summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deluge/core/torrent.py26
-rw-r--r--deluge/core/torrentmanager.py6
2 files changed, 28 insertions, 4 deletions
diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
index e46b16b37..f193410c9 100644
--- a/deluge/core/torrent.py
+++ b/deluge/core/torrent.py
@@ -169,6 +169,11 @@ class Torrent(object):
# Set the filename
self.filename = state.filename
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:
# Tracker list
self.trackers = []
@@ -181,6 +186,7 @@ class Torrent(object):
else:
tracker = value
self.trackers.append(tracker)
+ self.error_statusmsg = None
# Various torrent options
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
# 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
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():
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
+ else:
+ self.set_status_message("OK")
+ self.error_statusmsg = None
if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]:
if self.handle.is_paused():
@@ -803,6 +822,7 @@ class Torrent(object):
else:
# Reset the status message just in case of resuming an Error'd torrent
self.set_status_message("OK")
+ self.error_statusmsg = None
if self.handle.is_finished():
# If the torrent has already reached it's 'stop_seed_ratio' then do not do anything
@@ -839,7 +859,7 @@ class Torrent(object):
except TypeError:
# String is already unicode
pass
-
+
if not os.path.exists(dest):
try:
# Try to make the destination path if it doesn't exist
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index 1572f9a89..d4a548a4f 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -77,6 +77,7 @@ class TorrentState:
queue=None,
auto_managed=True,
is_finished=False,
+ error_statusmsg=None,
stop_ratio=2.00,
stop_at_ratio=False,
remove_at_ratio=False,
@@ -91,6 +92,7 @@ class TorrentState:
self.trackers = trackers
self.queue = queue
self.is_finished = is_finished
+ self.error_statusmsg = error_statusmsg
self.magnet = magnet
self.time_added = time_added
@@ -111,6 +113,7 @@ class TorrentState:
self.move_completed = move_completed
self.move_completed_path = move_completed_path
+
class TorrentManagerState:
def __init__(self):
self.torrents = []
@@ -672,7 +675,7 @@ class TorrentManager(component.Component):
# Create the state for each Torrent and append to the list
for torrent in self.torrents.values():
paused = False
- if torrent.state == "Paused":
+ if torrent.state in ["Paused", "Error"]:
paused = True
torrent_state = TorrentState(
@@ -692,6 +695,7 @@ class TorrentManager(component.Component):
torrent.get_queue_position(),
torrent.options["auto_managed"],
torrent.is_finished,
+ torrent.error_statusmsg,
torrent.options["stop_ratio"],
torrent.options["stop_at_ratio"],
torrent.options["remove_at_ratio"],