[#3478|Core] Fix loading magnet with resume_data and no metadata
Since libtorrent 1.2.10 magnets save resume_data even with metadata not yet downloaded. Unfortunately when using the deprecated add_torrent_params key resume_data results in an error "missing info-hash from URI" The problem is due to lt session requiring an info_hash in add_torrent_params but resume_data does not set or override this key and resume_data overrides the add_torrent_params.url with an empty string. The workaround is to specify the info_hash in add_torrent_params. We require sha1_hash object or bytes and use of bytearray to maintain python2 compatability. https://dev.deluge-torrent.org/ticket/3478
This commit is contained in:
parent
b89b2c45b1
commit
4b6c7d01b2
|
@ -441,6 +441,11 @@ class TorrentManager(component.Component):
|
||||||
add_torrent_params['url'] = magnet.strip().encode('utf8')
|
add_torrent_params['url'] = magnet.strip().encode('utf8')
|
||||||
add_torrent_params['name'] = magnet_info['name']
|
add_torrent_params['name'] = magnet_info['name']
|
||||||
torrent_id = magnet_info['info_hash']
|
torrent_id = magnet_info['info_hash']
|
||||||
|
# Workaround lt 1.2 bug for magnet resume data with no metadata
|
||||||
|
if resume_data and VersionSplit(LT_VERSION) >= VersionSplit('1.2.10.0'):
|
||||||
|
add_torrent_params['info_hash'] = bytes(
|
||||||
|
bytearray.fromhex(torrent_id)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise AddTorrentError(
|
raise AddTorrentError(
|
||||||
'Unable to add magnet, invalid magnet info: %s' % magnet
|
'Unable to add magnet, invalid magnet info: %s' % magnet
|
||||||
|
@ -1250,7 +1255,7 @@ class TorrentManager(component.Component):
|
||||||
def on_alert_add_torrent(self, alert):
|
def on_alert_add_torrent(self, alert):
|
||||||
"""Alert handler for libtorrent add_torrent_alert"""
|
"""Alert handler for libtorrent add_torrent_alert"""
|
||||||
if not alert.handle.is_valid():
|
if not alert.handle.is_valid():
|
||||||
log.warning('Torrent handle is invalid!')
|
log.warning('Torrent handle is invalid: %s', alert.error.message())
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue