[Core] Check valid torrent first in alert handlers
This commit is contained in:
parent
1e4a24c474
commit
bb44411a50
|
@ -943,13 +943,13 @@ class TorrentManager(component.Component):
|
||||||
torrent = self.torrents[torrent_id]
|
torrent = self.torrents[torrent_id]
|
||||||
except (RuntimeError, KeyError):
|
except (RuntimeError, KeyError):
|
||||||
return
|
return
|
||||||
log.debug('Finished %s ', torrent_id)
|
|
||||||
|
|
||||||
# If total_download is 0, do not move, it's likely the torrent wasn't downloaded, but just added.
|
# If total_download is 0, do not move, it's likely the torrent wasn't downloaded, but just added.
|
||||||
# Get fresh data from libtorrent, the cache isn't always up to date
|
# Get fresh data from libtorrent, the cache isn't always up to date
|
||||||
total_download = torrent.get_status(['total_payload_download'], update=True)['total_payload_download']
|
total_download = torrent.get_status(['total_payload_download'], update=True)['total_payload_download']
|
||||||
|
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
log.debug('Finished %s ', torrent_id)
|
||||||
log.debug('Torrent settings: is_finished: %s, total_download: %s, move_completed: %s, move_path: %s',
|
log.debug('Torrent settings: is_finished: %s, total_download: %s, move_completed: %s, move_path: %s',
|
||||||
torrent.is_finished, total_download, torrent.options['move_completed'],
|
torrent.is_finished, total_download, torrent.options['move_completed'],
|
||||||
torrent.options['move_completed_path'])
|
torrent.options['move_completed_path'])
|
||||||
|
@ -1045,6 +1045,11 @@ class TorrentManager(component.Component):
|
||||||
|
|
||||||
def on_alert_tracker_error(self, alert):
|
def on_alert_tracker_error(self, alert):
|
||||||
"""Alert handler for libtorrent tracker_error_alert"""
|
"""Alert handler for libtorrent tracker_error_alert"""
|
||||||
|
try:
|
||||||
|
torrent = self.torrents[str(alert.handle.info_hash())]
|
||||||
|
except (RuntimeError, KeyError):
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
error_message = decode_string(alert.error_message)
|
error_message = decode_string(alert.error_message)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -1055,11 +1060,6 @@ class TorrentManager(component.Component):
|
||||||
if not error_message:
|
if not error_message:
|
||||||
error_message = decode_string(alert.error.message())
|
error_message = decode_string(alert.error.message())
|
||||||
log.debug('Tracker Error Alert: %s [%s]', decode_string(alert.message()), error_message)
|
log.debug('Tracker Error Alert: %s [%s]', decode_string(alert.message()), error_message)
|
||||||
try:
|
|
||||||
torrent = self.torrents[str(alert.handle.info_hash())]
|
|
||||||
except (RuntimeError, KeyError):
|
|
||||||
return
|
|
||||||
|
|
||||||
torrent.set_tracker_status('Error: ' + error_message)
|
torrent.set_tracker_status('Error: ' + error_message)
|
||||||
|
|
||||||
def on_alert_storage_moved(self, alert):
|
def on_alert_storage_moved(self, alert):
|
||||||
|
@ -1156,14 +1156,14 @@ class TorrentManager(component.Component):
|
||||||
|
|
||||||
def on_alert_fastresume_rejected(self, alert):
|
def on_alert_fastresume_rejected(self, alert):
|
||||||
"""Alert handler for libtorrent fastresume_rejected_alert"""
|
"""Alert handler for libtorrent fastresume_rejected_alert"""
|
||||||
alert_msg = decode_string(alert.message())
|
|
||||||
log.error('on_alert_fastresume_rejected: %s', alert_msg)
|
|
||||||
try:
|
try:
|
||||||
torrent_id = str(alert.handle.info_hash())
|
torrent_id = str(alert.handle.info_hash())
|
||||||
torrent = self.torrents[torrent_id]
|
torrent = self.torrents[torrent_id]
|
||||||
except (RuntimeError, KeyError):
|
except (RuntimeError, KeyError):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
alert_msg = decode_string(alert.message())
|
||||||
|
log.error('on_alert_fastresume_rejected: %s', alert_msg)
|
||||||
if alert.error.value() == 134:
|
if alert.error.value() == 134:
|
||||||
if not os.path.isdir(torrent.options['download_location']):
|
if not os.path.isdir(torrent.options['download_location']):
|
||||||
error_msg = 'Unable to locate Download Folder!'
|
error_msg = 'Unable to locate Download Folder!'
|
||||||
|
@ -1180,17 +1180,18 @@ class TorrentManager(component.Component):
|
||||||
TorrentFileRenamedEvent: Files in the torrent have been renamed.
|
TorrentFileRenamedEvent: Files in the torrent have been renamed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
torrent_id = str(alert.handle.info_hash())
|
||||||
|
torrent = self.torrents[torrent_id]
|
||||||
|
except (RuntimeError, KeyError):
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
new_name = decode_string(alert.new_name)
|
new_name = decode_string(alert.new_name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# Deprecated in libtorrent 1.1
|
# Deprecated in libtorrent 1.1
|
||||||
new_name = decode_string(alert.name)
|
new_name = decode_string(alert.name)
|
||||||
log.debug('index: %s name: %s', alert.index, new_name)
|
log.debug('index: %s name: %s', alert.index, new_name)
|
||||||
try:
|
|
||||||
torrent_id = str(alert.handle.info_hash())
|
|
||||||
torrent = self.torrents[torrent_id]
|
|
||||||
except (RuntimeError, KeyError):
|
|
||||||
return
|
|
||||||
|
|
||||||
# We need to see if this file index is in a waiting_on_folder dict
|
# We need to see if this file index is in a waiting_on_folder dict
|
||||||
for wait_on_folder in torrent.waiting_on_folder_rename:
|
for wait_on_folder in torrent.waiting_on_folder_rename:
|
||||||
|
|
Loading…
Reference in New Issue