Skip to content
Snippets Groups Projects
Commit 9c9971bb authored by q3k's avatar q3k
Browse files

st3m: correcly merge settings dicts

This makes settings persistence actually work.
parent f979318a
No related branches found
No related tags found
No related merge requests found
Pipeline #6815 passed
......@@ -320,13 +320,25 @@ def load_all() -> None:
setting.load(data)
def _update(d: Dict[str, Any], u: Dict[str, Any]) -> Dict[str, Any]:
"""
Recursive update dictionary.
"""
for k, v in u.items():
if type(v) == type({}):
d[k] = _update(d.get(k, {}), v)
else:
d[k] = v
return d
def save_all() -> None:
"""
Save all settings to flash.
"""
res = {}
res: Dict[str, Any] = {}
for setting in all_settings:
res.update(setting.save())
res = _update(res, setting.save())
try:
with open("/flash/settings.json", "w") as f:
json.dump(res, f)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment