Allow incomplete options dictionaries when adding a torrent. The

missing keys will be replaced by defaults.
This commit is contained in:
Andrew Resch 2008-02-07 07:20:17 +00:00
commit 9a1d5e9bfa

View file

@ -174,7 +174,6 @@ class TorrentManager(component.Component):
handle = None handle = None
# Check if options is None and load defaults # Check if options is None and load defaults
if options == None:
options_keys = [ options_keys = [
"compact_allocation", "compact_allocation",
"max_connections_per_torrent", "max_connections_per_torrent",
@ -186,9 +185,15 @@ class TorrentManager(component.Component):
"add_paused", "add_paused",
"default_private" "default_private"
] ]
if options == None:
options = {} options = {}
for key in options_keys: for key in options_keys:
options[key] = self.config[key] options[key] = self.config[key]
else:
for key in options_keys:
if not options.has_key(key):
options[key] = self.config[key]
if paused is None: if paused is None:
paused = options["add_paused"] paused = options["add_paused"]