Add super_seeding to core

This commit is contained in:
Calum Lind 2014-01-18 18:40:07 +00:00
parent 3180bc7104
commit 246708e222
4 changed files with 28 additions and 8 deletions

View File

@ -623,6 +623,11 @@ class Core(component.Component):
"""Sets the path for the torrent to be moved when completed""" """Sets the path for the torrent to be moved when completed"""
return self.torrentmanager[torrent_id].set_move_completed_path(value) 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) @export(AUTH_LEVEL_ADMIN)
def set_torrents_owner(self, torrent_ids, username): def set_torrents_owner(self, torrent_ids, username):
"""Set's the torrent owner. """Set's the torrent owner.

View File

@ -148,7 +148,8 @@ DEFAULT_PREFS = {
"cache_size": 512, "cache_size": 512,
"cache_expiry": 60, "cache_expiry": 60,
"auto_manage_prefer_seeds": False, "auto_manage_prefer_seeds": False,
"shared": False "shared": False,
"super_seeding": False
} }

View File

@ -100,7 +100,8 @@ class TorrentOptions(dict):
"move_completed": "move_completed", "move_completed": "move_completed",
"move_completed_path": "move_completed_path", "move_completed_path": "move_completed_path",
"add_paused": "add_paused", "add_paused": "add_paused",
"shared": "shared" "shared": "shared",
"super_seeding": "super_seeding"
} }
for opt_k, conf_k in options_conf_map.iteritems(): for opt_k, conf_k in options_conf_map.iteritems():
self[opt_k] = config[conf_k] self[opt_k] = config[conf_k]
@ -331,6 +332,13 @@ class Torrent(object):
self.handle.auto_managed(auto_managed) self.handle.auto_managed(auto_managed)
self.update_state() 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): def set_stop_ratio(self, stop_ratio):
self.options["stop_ratio"] = stop_ratio self.options["stop_ratio"] = stop_ratio
@ -678,7 +686,6 @@ class Torrent(object):
self.status = status self.status = status
def _create_status_funcs(self): def _create_status_funcs(self):
#if you add a key here->add it to core.py STATUS_KEYS too.
self.status_funcs = { self.status_funcs = {
"active_time": lambda: self.status.active_time, "active_time": lambda: self.status.active_time,
"all_time_download": lambda: self.status.all_time_download, "all_time_download": lambda: self.status.all_time_download,
@ -741,13 +748,15 @@ class Torrent(object):
"files": self.get_files, "files": self.get_files,
"is_seed": lambda: self.status.is_seeding, "is_seed": lambda: self.status.is_seeding,
"peers": self.get_peers, "peers": self.get_peers,
"queue": self.handle.queue_position, "queue": lambda: self.status.queue_position,
"ratio": self.get_ratio, "ratio": self.get_ratio,
"tracker_host": self.get_tracker_host, "tracker_host": self.get_tracker_host,
"completed_time": lambda: self.status.completed_time, "completed_time": lambda: self.status.completed_time,
"last_seen_complete": lambda: self.status.last_seen_complete, "last_seen_complete": lambda: self.status.last_seen_complete,
"name": self.get_name, "name": self.get_name,
"pieces": self._get_pieces_info, "pieces": self._get_pieces_info,
"seed_mode": lambda: self.status.seed_mode,
"super_seeding": lambda: self.status.super_seeding,
} }
def get_name(self): def get_name(self):

View File

@ -88,7 +88,9 @@ class TorrentState:
magnet=None, magnet=None,
time_added=-1, time_added=-1,
owner=None, owner=None,
shared=False): shared=False,
super_seeding=False
):
self.torrent_id = torrent_id self.torrent_id = torrent_id
self.filename = filename self.filename = filename
self.trackers = trackers self.trackers = trackers
@ -116,6 +118,7 @@ class TorrentState:
self.move_completed = move_completed self.move_completed = move_completed
self.move_completed_path = move_completed_path self.move_completed_path = move_completed_path
self.shared = shared self.shared = shared
self.super_seeding = super_seeding
class TorrentManagerState: class TorrentManagerState:
@ -351,6 +354,7 @@ class TorrentManager(component.Component):
options["move_completed_path"] = state.move_completed_path options["move_completed_path"] = state.move_completed_path
options["add_paused"] = state.paused options["add_paused"] = state.paused
options["shared"] = state.shared options["shared"] = state.shared
options["super_seeding"] = state.super_seeding
owner = state.owner owner = state.owner
torrent_info = self.get_torrent_info_from_file( torrent_info = self.get_torrent_info_from_file(
@ -440,8 +444,8 @@ class TorrentManager(component.Component):
add_torrent_params["storage_mode"] = storage_mode add_torrent_params["storage_mode"] = storage_mode
default_flags = (lt.add_torrent_params_flags_t.flag_paused | 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_auto_managed |
lt.add_torrent_params_flags_t.flag_update_subscribe| lt.add_torrent_params_flags_t.flag_update_subscribe |
lt.add_torrent_params_flags_t.flag_apply_ip_filter) lt.add_torrent_params_flags_t.flag_apply_ip_filter)
# Set flags: enable duplicate_is_error and disable auto_managed # Set flags: enable duplicate_is_error and disable auto_managed
add_torrent_params["flags"] = ((default_flags add_torrent_params["flags"] = ((default_flags
@ -691,7 +695,8 @@ class TorrentManager(component.Component):
torrent.magnet, torrent.magnet,
torrent.time_added, torrent.time_added,
torrent.owner, torrent.owner,
torrent.options["shared"] torrent.options["shared"],
torrent.options["super_seeding"]
) )
state.torrents.append(torrent_state) state.torrents.append(torrent_state)