@@ -289,10 +289,13 @@ def set_throttle(self, name):
289289 if name .lower () == "null" :
290290 name = "NULL"
291291 if name .lower () == "none" :
292- name = ""
292+ name = ''
293293
294- if (name or "NONE" ) not in config .throttle_names :
295- raise error .UserError ("Unknown throttle name %r" % (name or "NONE" ,))
294+ if name not in self ._engine .known_throttle_names :
295+ if self ._engine ._rpc .throttle .up .max (xmlrpc .NOHASH , name ) == - 1 :
296+ if self ._engine ._rpc .throttle .down .max (xmlrpc .NOHASH , name ) == - 1 :
297+ raise error .UserError ("Unknown throttle name '{}'" .format (name ))
298+ self ._engine .known_throttle_names .add (name )
296299
297300 if (name or "NONE" ) == self .throttle :
298301 self ._engine .LOG .debug ("Keeping throttle %r on torrent #%s" % (self .throttle , self ._fields ["hash" ]))
@@ -507,20 +510,14 @@ def flush(self):
507510class RtorrentEngine (engine .TorrentEngine ):
508511 """ The rTorrent backend proxy.
509512 """
510- # throttling config keys
511- RTORRENT_RC_THROTTLE_KEYS = ("throttle_up" , "throttle_down" , "throttle_ip" , )
512-
513513 # keys we read from rTorrent's configuration
514- RTORRENT_RC_KEYS = ("scgi_local" , "scgi_port" , "log.execute" ) + RTORRENT_RC_THROTTLE_KEYS
514+ RTORRENT_RC_KEYS = ("scgi_local" , "scgi_port" , "log.execute" )
515515
516516 # mapping from new to old commands, and thus our config keys
517517 RTORRENT_RC_ALIASES = {
518518 "network.scgi.open_local" : "scgi_local" ,
519519 "network.scgi.open_port" : "scgi_port" ,
520520 #"log.execute": "",
521- "throttle.up" : "throttle_up" ,
522- "throttle.down" : "throttle_down" ,
523- "throttle.ip" : "throttle_ip" ,
524521 }
525522
526523 # rTorrent names of fields that never change
@@ -572,6 +569,7 @@ def __init__(self):
572569 self ._session_dir = None
573570 self ._download_dir = None
574571 self ._item_cache = {}
572+ self .known_throttle_names = {'' , 'NULL' }
575573
576574
577575 def load_config (self , namespace = None , rcfile = None ):
@@ -615,11 +613,7 @@ def cfgkey(key):
615613 key = self .RTORRENT_RC_ALIASES .get (key , key )
616614
617615 # Copy values we're interested in
618- if key in self .RTORRENT_RC_THROTTLE_KEYS :
619- val = val .split (',' )[0 ].strip ()
620- self .LOG .debug ("rtorrent.rc: added throttle %r" % (val ,))
621- namespace .throttle_names .add (val )
622- elif key in self .RTORRENT_RC_KEYS and not getattr (namespace , cfgkey (key ), None ):
616+ if key in self .RTORRENT_RC_KEYS and not getattr (namespace , cfgkey (key ), None ):
623617 self .LOG .debug ("rtorrent.rc: %s = %s" % (key , val ))
624618 setattr (namespace , cfgkey (key ), val )
625619
0 commit comments