[Core] Update to support libtorrent 1.2

Some changes between lt 1.1 and 1.2 require updates to core code.
 - Switch from proxy_type to proxy_type_t
 - Replace hardcoded flag value with add_torrent_params_flags_t since
   1.2 uses different flag values.
 - add_torrent_params requires flags set instead of dict values.

Refs: #3255
This commit is contained in:
DjLegolas 2019-05-25 19:50:54 +03:00 committed by Calum Lind
parent cbf9ee8978
commit d40d40af31
3 changed files with 22 additions and 11 deletions

View File

@ -426,7 +426,7 @@ class PreferencesManager(component.Component):
def _on_set_proxy(self, key, value):
# Initialise with type none and blank hostnames.
proxy_settings = {
'proxy_type': lt.proxy_type.none,
'proxy_type': lt.proxy_type_t.none,
'i2p_hostname': '',
'proxy_hostname': '',
'proxy_hostnames': value['proxy_hostnames'],
@ -436,15 +436,15 @@ class PreferencesManager(component.Component):
'anonymous_mode': value['anonymous_mode'],
}
if value['type'] == lt.proxy_type.i2p_proxy:
if value['type'] == lt.proxy_type_t.i2p_proxy:
proxy_settings.update(
{
'proxy_type': lt.proxy_type.i2p_proxy,
'proxy_type': lt.proxy_type_t.i2p_proxy,
'i2p_hostname': value['hostname'],
'i2p_port': value['port'],
}
)
elif value['type'] != lt.proxy_type.none:
elif value['type'] != lt.proxy_type_t.none:
proxy_settings.update(
{
'proxy_type': value['type'],

View File

@ -23,6 +23,7 @@ from twisted.web.static import File
import deluge.common
import deluge.component as component
import deluge.core.torrent
from deluge._libtorrent import lt
from deluge.core.core import Core
from deluge.core.rpcserver import RPCServer
from deluge.error import AddTorrentError, InvalidTorrentError
@ -116,7 +117,13 @@ class CoreTestCase(BaseTestCase):
def add_torrent(self, filename, paused=False):
if not paused:
# Patch libtorrent flags starting torrents paused
self.patch(deluge.core.torrentmanager, 'LT_DEFAULT_ADD_TORRENT_FLAGS', 592)
self.patch(
deluge.core.torrentmanager,
'LT_DEFAULT_ADD_TORRENT_FLAGS',
lt.add_torrent_params_flags_t.flag_auto_managed
| lt.add_torrent_params_flags_t.flag_update_subscribe
| lt.add_torrent_params_flags_t.flag_apply_ip_filter,
)
options = {'add_paused': paused, 'auto_managed': False}
filepath = common.get_test_data_file(filename)
with open(filepath, 'rb') as _file:

View File

@ -73,12 +73,16 @@ class TorrentTestCase(BaseTestCase):
filename = common.get_test_data_file(filename)
with open(filename, 'rb') as _file:
info = lt.torrent_info(lt.bdecode(_file.read()))
atp = {'ti': info}
atp['save_path'] = os.getcwd()
atp['storage_mode'] = lt.storage_mode_t.storage_mode_sparse
atp['add_paused'] = False
atp['auto_managed'] = True
atp['duplicate_is_error'] = True
atp = {
'ti': info,
'save_path': os.getcwd(),
'storage_mode': lt.storage_mode_t.storage_mode_sparse,
'flags': (
lt.add_torrent_params_flags_t.flag_auto_managed
| lt.add_torrent_params_flags_t.flag_duplicate_is_error
& ~lt.add_torrent_params_flags_t.flag_paused
),
}
return atp
def test_set_file_priorities(self):