mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 04:24:27 +00:00
add type checking to config values (Closes: #353)
This commit is contained in:
parent
0ed48a6cd8
commit
8d05d4f2c5
@ -114,7 +114,16 @@ class Config:
|
||||
"""Set the 'key' with 'value'."""
|
||||
# Sets the "key" with "value" in the config dict
|
||||
if self.config[key] != value:
|
||||
log.debug("Setting '%s' to %s of %s", key, value, type(value))
|
||||
oldtype, newtype = type(self.config[key]), type(value)
|
||||
if oldtype != newtype:
|
||||
try:
|
||||
value = oldtype(value)
|
||||
except ValueError:
|
||||
log.warning("Type '%s' invalid for '%s'", newtype, key)
|
||||
return
|
||||
|
||||
log.debug("Setting '%s' to %s of %s", key, value, oldtype)
|
||||
|
||||
# Make a copy of the current config prior to changing it
|
||||
self.previous_config = self.config.copy()
|
||||
self.config[key] = value
|
||||
|
Loading…
x
Reference in New Issue
Block a user