summaryrefslogtreecommitdiffstats
path: root/deluge/core/torrentmanager.py
diff options
context:
space:
mode:
authorDjLegolas <DjLegolas@protonmail.com>2020-05-02 21:21:53 +0300
committerCalum Lind <calumlind+deluge@gmail.com>2021-04-17 16:55:54 +0100
commit8676a0d2a0cc0fc36f2c366194f188ea947f4b1f (patch)
treedd3295a159273560bc140eded3920953f2d24f6d /deluge/core/torrentmanager.py
parent3ec23ad96bfa205c8ae23b662c6da153efbfed3a (diff)
downloaddeluge-8676a0d2a0cc0fc36f2c366194f188ea947f4b1f.tar.gz
deluge-8676a0d2a0cc0fc36f2c366194f188ea947f4b1f.tar.bz2
deluge-8676a0d2a0cc0fc36f2c366194f188ea947f4b1f.zip
[Core] Improve on_alert_tracker_error for lt >= 1.2
libtorrent 1.2 added endpoint struct to each tracker, to prevent false updates we will need to verify that at least one endpoint to the errored tracker is working. if there is at least one working, it will not set the tracker status to error and set it to `Announce OK`. otherwise, it will use the error message from the alert. Refs: https://dev.deluge-torrent.org/ticket/3384
Diffstat (limited to 'deluge/core/torrentmanager.py')
-rw-r--r--deluge/core/torrentmanager.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index b94868776..7ad837bbe 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -24,8 +24,15 @@ from twisted.internet.defer import Deferred, DeferredList
from twisted.internet.task import LoopingCall
import deluge.component as component
-from deluge._libtorrent import lt
-from deluge.common import PY2, archive_files, decode_bytes, get_magnet_info, is_magnet
+from deluge._libtorrent import LT_VERSION, lt
+from deluge.common import (
+ PY2,
+ VersionSplit,
+ archive_files,
+ decode_bytes,
+ get_magnet_info,
+ is_magnet,
+)
from deluge.configmanager import ConfigManager, get_config_dir
from deluge.core.authmanager import AUTH_LEVEL_ADMIN
from deluge.core.torrent import Torrent, TorrentOptions, sanitize_filepath
@@ -1392,7 +1399,22 @@ class TorrentManager(component.Component):
log.debug(
'Tracker Error Alert: %s [%s]', decode_bytes(alert.message()), error_message
)
- torrent.set_tracker_status('Error: ' + error_message)
+ if VersionSplit(LT_VERSION) >= VersionSplit('1.2.0.0'):
+ # libtorrent 1.2 added endpoint struct to each tracker. to prevent false updates
+ # we will need to verify that at least one endpoint to the errored tracker is working
+ for tracker in torrent.handle.trackers():
+ if tracker['url'] == alert.url:
+ if any(
+ endpoint['last_error']['value'] == 0
+ for endpoint in tracker['endpoints']
+ ):
+ torrent.set_tracker_status('Announce OK')
+ else:
+ torrent.set_tracker_status('Error: ' + error_message)
+ break
+ else:
+ # preserve old functionality for libtorrent < 1.2
+ torrent.set_tracker_status('Error: ' + error_message)
def on_alert_storage_moved(self, alert):
"""Alert handler for libtorrent storage_moved_alert"""