Error adding magnet with resume data "missing info-hash from URI"
It seems a regression was introduced by the following changes to allow magnets to save resume data before metadata has been downloaded:
- https://github.com/arvidn/libtorrent/pull/5171/
- https://github.com/arvidn/libtorrent/pull/5247
The problem is magnets with no metadata cannot be added back to the session with resume data specified in the add_torrent method without erroring:
ses = lt.session()
atp = {'url': b'magnet:?xt=urn:btih:85bbba4035cca750f681284857f53e405eb41f8d', 'name': '85bbba4035cca750f681284857f53e405eb41f8d', 'save_path': b'/home/calum/Downloads', 'resume_data': b'd11:active_timei2e10:added_timei1629645832e10:allocation6:sparse15:apply_ip_filteri1e12:auto_managedi1e14:completed_timei0e11:disable_dhti0e11:disable_lsdi0e11:disable_pexi0e19:download_rate_limiti-1e11:file-format22:libtorrent resume file12:file-versioni1e13:finished_timei0e9:httpseedsle9:info-hash20:\x85\xbb\xba@5\xcc\xa7P\xf6\x81(HW\xf5>@^\xb4\x1f\x8d13:last_downloadi0e18:last_seen_completei0e11:last_uploadi0e18:libtorrent-version8:1.2.14.015:max_connectionsi16777215e11:max_uploadsi16777215e4:name40:85bbba4035cca750f681284857f53e405eb41f8d12:num_completei16777215e14:num_downloadedi16777215e14:num_incompletei16777215e6:pausedi0e5:peers12:\xc0\xa8\x01y\xf2"\xc0\xa8\x01\xc8\xf2"6:peers60:6:pieces0:9:save_path21:/home/calum/Downloads9:seed_modei0e12:seeding_timei0e19:sequential_downloadi0e10:share_modei0e15:stop_when_readyi0e13:super_seedingi0e16:total_downloadedi0e14:total_uploadedi0e8:trackersle11:upload_modei0e17:upload_rate_limiti-1e8:url-listlee', 'flags': 32984}
ses.add_torrent(atp)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: missing info-hash from URI
If ti is provided there is no issue since the info_hash is set from it.
The workaround for now is to specify the info_hash in atp, remembering to convert from hex to bytes so sha1_hash converts correctly:
add_torrent_params['info_hash'] = bytes.fromhex(magnet_info_hash)
The fix might be to set atp.info_hash in handle_backwards_compatible_resume_data
I know that Deluge needs to be updated to no longer use deprecated args but current version needs to support lt 1.1 and 1.2.
libtorrent version (or branch): 1.2.14 Deluge issue: https://dev.deluge-torrent.org/ticket/3478
Thanks for this @cas-- saved me some aggravation.
could anyone give this a try? https://github.com/arvidn/libtorrent/pull/6853
Works
could anyone give this a try? #6853