Changeset b0c3c3


Ignore:
Timestamp:
01/17/2014 10:48:42 AM (12 years ago)
Author:
Calum Lind <calumlind+deluge@gmail.com>
Branches:
2.0.x, develop, master
Children:
624f2f
Parents:
8eb215
git-author:
Calum Lind <calumlind+deluge@gmail.com> (01/17/2014 10:48:32 AM)
git-committer:
Calum Lind <calumlind+deluge@gmail.com> (01/17/2014 10:48:42 AM)
Message:

Use non-deprecated libtorrent parameters and functions

Also added support for seed_mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • deluge/core/torrentmanager.py

    r8eb215 rb0c3c3  
    316316
    317317    def add(self, torrent_info=None, state=None, options=None, save_state=True,
    318             filedump=None, filename=None, magnet=None, resume_data=None, owner=None):
     318            filedump=None, filename=None, magnet=None, resume_data=None, seed_mode=False, owner=None):
    319319        """Add a torrent to the manager and returns it's torrent_id"""
    320320        if torrent_info is None and state is None and filedump is None and magnet is None:
     
    442442        add_torrent_params["save_path"] = utf8_encoded(options["download_location"])
    443443        add_torrent_params["storage_mode"] = storage_mode
    444         add_torrent_params["paused"] = True
    445         add_torrent_params["auto_managed"] = False
    446         add_torrent_params["duplicate_is_error"] = True
     444        add_torrent_params["flags"] = (lt.add_torrent_params_flags_t.flag_paused |
     445                                       lt.add_torrent_params_flags_t.flag_duplicate_is_error)
     446        if seed_mode:
     447            add_torrent_params["flags"] |= lt.add_torrent_params_flags_t.flag_seed_mode
     448        if magnet:
     449            add_torrent_params["url"] = utf8_encoded(magnet)
    447450
    448451        # We need to pause the AlertManager momentarily to prevent alerts
     
    452455        handle = None
    453456        try:
    454             if magnet:
    455                 handle = lt.add_magnet_uri(self.session, utf8_encoded(magnet), add_torrent_params)
    456             else:
    457                 handle = self.session.add_torrent(add_torrent_params)
     457            handle = self.session.add_torrent(add_torrent_params)
    458458        except RuntimeError as ex:
    459459            log.warning("Error adding torrent: %s", ex)
Note: See TracChangeset for help on using the changeset viewer.