[Core] Stop using libtorrent.add_torrent_params_flags_t

The `libtorrent.add_torrent_params_flags_t` is deprecated and when
`libtorrent` is being compiled without deprecated functionality, we will
fail on `AttributeError`.

Refs: 4947602a2f
Closes: https://dev.deluge-torrent.org/ticket/3581
Closes: https://github.com/deluge-torrent/deluge/pull/407
This commit is contained in:
DjLegolas 2023-01-22 22:38:31 +02:00 committed by Calum Lind
parent 4de754328f
commit 5d7b416373
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
3 changed files with 17 additions and 22 deletions

View File

@ -50,10 +50,10 @@ from deluge.event import (
log = logging.getLogger(__name__)
LT_DEFAULT_ADD_TORRENT_FLAGS = (
lt.add_torrent_params_flags_t.flag_paused
| 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
lt.torrent_flags.paused
| lt.torrent_flags.auto_managed
| lt.torrent_flags.update_subscribe
| lt.torrent_flags.apply_ip_filter
)
@ -369,11 +369,11 @@ class TorrentManager(component.Component):
add_torrent_params.flags = (
(
LT_DEFAULT_ADD_TORRENT_FLAGS
| lt.add_torrent_params_flags_t.flag_duplicate_is_error
| lt.add_torrent_params_flags_t.flag_upload_mode
| lt.torrent_flags.duplicate_is_error
| lt.torrent_flags.upload_mode
)
^ lt.add_torrent_params_flags_t.flag_auto_managed
^ lt.add_torrent_params_flags_t.flag_paused
^ lt.torrent_flags.auto_managed
^ lt.torrent_flags.paused
)
torrent_handle = self.session.add_torrent(add_torrent_params)
@ -481,16 +481,12 @@ class TorrentManager(component.Component):
# Set flags: enable duplicate_is_error & override_resume_data, disable auto_managed.
add_torrent_params['flags'] = (
LT_DEFAULT_ADD_TORRENT_FLAGS
| lt.add_torrent_params_flags_t.flag_duplicate_is_error
| lt.add_torrent_params_flags_t.flag_override_resume_data
) ^ lt.add_torrent_params_flags_t.flag_auto_managed
LT_DEFAULT_ADD_TORRENT_FLAGS | lt.torrent_flags.duplicate_is_error
) ^ lt.torrent_flags.auto_managed
if options['seed_mode']:
add_torrent_params['flags'] |= lt.add_torrent_params_flags_t.flag_seed_mode
add_torrent_params['flags'] |= lt.torrent_flags.seed_mode
if options['super_seeding']:
add_torrent_params[
'flags'
] |= lt.add_torrent_params_flags_t.flag_super_seeding
add_torrent_params['flags'] |= lt.torrent_flags.super_seeding
return torrent_id, add_torrent_params

View File

@ -116,9 +116,9 @@ class TestCore(BaseTestCase):
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,
lt.torrent_flags.auto_managed
| lt.torrent_flags.update_subscribe
| lt.torrent_flags.apply_ip_filter,
)
options = {'add_paused': paused, 'auto_managed': False}
filepath = common.get_test_data_file(filename)

View File

@ -74,9 +74,8 @@ class TestTorrent(BaseTestCase):
'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
lt.torrent_flags.auto_managed
| lt.torrent_flags.duplicate_is_error & ~lt.torrent_flags.paused
),
}
return atp