Raise error if loading a JSON fails
Don't use the default config if there's an error in a JSON config file, a single typo could lead to an entire user settings file getting overwritten by default data.
This commit is contained in:
parent
75fbf23b21
commit
6ce3059322
|
@ -188,11 +188,7 @@ class JSONFile(MappingFile):
|
||||||
returned dict and the second tuple item will be `True`.
|
returned dict and the second tuple item will be `True`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
loaded = json.loads(data)
|
||||||
loaded = json.loads(data)
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
loaded = {}
|
|
||||||
|
|
||||||
all_data = self.default_data.copy()
|
all_data = self.default_data.copy()
|
||||||
dict_update_recursive(all_data, loaded)
|
dict_update_recursive(all_data, loaded)
|
||||||
return (all_data, loaded != all_data)
|
return (all_data, loaded != all_data)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user