From 246708e222552697232d8cc1c44eec43fdfc4dc5 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sat, 18 Jan 2014 18:40:07 +0000 Subject: [PATCH] Add super_seeding to core --- deluge/core/core.py | 5 +++++ deluge/core/preferencesmanager.py | 3 ++- deluge/core/torrent.py | 15 ++++++++++++--- deluge/core/torrentmanager.py | 13 +++++++++---- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index d9866e1c1..0296dc559 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -623,6 +623,11 @@ class Core(component.Component): """Sets the path for the torrent to be moved when completed""" return self.torrentmanager[torrent_id].set_move_completed_path(value) + @export + def set_torrent_super_seeding(self, torrent_id, value): + """Sets the path for the torrent to be moved when completed""" + return self.torrentmanager[torrent_id].set_super_seeding(value) + @export(AUTH_LEVEL_ADMIN) def set_torrents_owner(self, torrent_ids, username): """Set's the torrent owner. diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index 10c902851..3678265a0 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -148,7 +148,8 @@ DEFAULT_PREFS = { "cache_size": 512, "cache_expiry": 60, "auto_manage_prefer_seeds": False, - "shared": False + "shared": False, + "super_seeding": False } diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index d2a2d0705..7e14b6132 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -100,7 +100,8 @@ class TorrentOptions(dict): "move_completed": "move_completed", "move_completed_path": "move_completed_path", "add_paused": "add_paused", - "shared": "shared" + "shared": "shared", + "super_seeding": "super_seeding" } for opt_k, conf_k in options_conf_map.iteritems(): self[opt_k] = config[conf_k] @@ -331,6 +332,13 @@ class Torrent(object): self.handle.auto_managed(auto_managed) self.update_state() + def set_super_seeding(self, super_seeding): + if super_seeding and self.status.is_seed: + self.options["super_seeding"] = True + self.handle.super_seeding(True) + else: + self.options["super_seeding"] = False + def set_stop_ratio(self, stop_ratio): self.options["stop_ratio"] = stop_ratio @@ -678,7 +686,6 @@ class Torrent(object): self.status = status def _create_status_funcs(self): - #if you add a key here->add it to core.py STATUS_KEYS too. self.status_funcs = { "active_time": lambda: self.status.active_time, "all_time_download": lambda: self.status.all_time_download, @@ -741,13 +748,15 @@ class Torrent(object): "files": self.get_files, "is_seed": lambda: self.status.is_seeding, "peers": self.get_peers, - "queue": self.handle.queue_position, + "queue": lambda: self.status.queue_position, "ratio": self.get_ratio, "tracker_host": self.get_tracker_host, "completed_time": lambda: self.status.completed_time, "last_seen_complete": lambda: self.status.last_seen_complete, "name": self.get_name, "pieces": self._get_pieces_info, + "seed_mode": lambda: self.status.seed_mode, + "super_seeding": lambda: self.status.super_seeding, } def get_name(self): diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 2fd3be13c..aa4bbb005 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -88,7 +88,9 @@ class TorrentState: magnet=None, time_added=-1, owner=None, - shared=False): + shared=False, + super_seeding=False + ): self.torrent_id = torrent_id self.filename = filename self.trackers = trackers @@ -116,6 +118,7 @@ class TorrentState: self.move_completed = move_completed self.move_completed_path = move_completed_path self.shared = shared + self.super_seeding = super_seeding class TorrentManagerState: @@ -351,6 +354,7 @@ class TorrentManager(component.Component): options["move_completed_path"] = state.move_completed_path options["add_paused"] = state.paused options["shared"] = state.shared + options["super_seeding"] = state.super_seeding owner = state.owner torrent_info = self.get_torrent_info_from_file( @@ -440,8 +444,8 @@ class TorrentManager(component.Component): add_torrent_params["storage_mode"] = storage_mode default_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_auto_managed | + lt.add_torrent_params_flags_t.flag_update_subscribe | lt.add_torrent_params_flags_t.flag_apply_ip_filter) # Set flags: enable duplicate_is_error and disable auto_managed add_torrent_params["flags"] = ((default_flags @@ -691,7 +695,8 @@ class TorrentManager(component.Component): torrent.magnet, torrent.time_added, torrent.owner, - torrent.options["shared"] + torrent.options["shared"], + torrent.options["super_seeding"] ) state.torrents.append(torrent_state)