mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-16 13:26:33 +00:00
[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
This commit is contained in:
parent
3ec23ad96b
commit
8676a0d2a0
@ -994,6 +994,8 @@ class Torrent(object):
|
||||
call to get_status based on the session_id
|
||||
update (bool): If True the status will be updated from libtorrent
|
||||
if False, the cached values will be returned
|
||||
all_keys (bool): If True return all keys while ignoring the keys param
|
||||
if False, return only the requested keys
|
||||
|
||||
Returns:
|
||||
dict: a dictionary of the status keys and their values
|
||||
|
@ -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"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user