From b0c3c3dddc50d3e738df88e214354118282c54cf Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 17 Jan 2014 10:48:32 +0000 Subject: [PATCH] Use non-deprecated libtorrent parameters and functions Also added support for seed_mode --- deluge/core/torrentmanager.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 68ecb1a42..0d3361d00 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -315,7 +315,7 @@ class TorrentManager(component.Component): return torrent_info def add(self, torrent_info=None, state=None, options=None, save_state=True, - filedump=None, filename=None, magnet=None, resume_data=None, owner=None): + filedump=None, filename=None, magnet=None, resume_data=None, seed_mode=False, owner=None): """Add a torrent to the manager and returns it's torrent_id""" if torrent_info is None and state is None and filedump is None and magnet is None: log.debug("You must specify a valid torrent_info, torrent state or magnet.") @@ -441,9 +441,12 @@ class TorrentManager(component.Component): # Fill in the rest of the add_torrent_params dictionary add_torrent_params["save_path"] = utf8_encoded(options["download_location"]) add_torrent_params["storage_mode"] = storage_mode - add_torrent_params["paused"] = True - add_torrent_params["auto_managed"] = False - add_torrent_params["duplicate_is_error"] = True + add_torrent_params["flags"] = (lt.add_torrent_params_flags_t.flag_paused | + lt.add_torrent_params_flags_t.flag_duplicate_is_error) + if seed_mode: + add_torrent_params["flags"] |= lt.add_torrent_params_flags_t.flag_seed_mode + if magnet: + add_torrent_params["url"] = utf8_encoded(magnet) # We need to pause the AlertManager momentarily to prevent alerts # for this torrent being generated before a Torrent object is created. @@ -451,10 +454,7 @@ class TorrentManager(component.Component): handle = None try: - if magnet: - handle = lt.add_magnet_uri(self.session, utf8_encoded(magnet), add_torrent_params) - else: - handle = self.session.add_torrent(add_torrent_params) + handle = self.session.add_torrent(add_torrent_params) except RuntimeError as ex: log.warning("Error adding torrent: %s", ex)