From 44f04887dc9c28d23dff81f3d1090bae5ed343e1 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 16 Jun 2026 17:29:41 -0400 Subject: [PATCH] Add missing save_config() to config.py (was imported by server.py but never pushed) --- src/system/config.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/system/config.py b/src/system/config.py index 7acf006..5cbb09d 100644 --- a/src/system/config.py +++ b/src/system/config.py @@ -87,4 +87,20 @@ def _deep_merge(base: dict, overrides: dict) -> None: if key in base and isinstance(base[key], dict) and isinstance(val, dict): _deep_merge(base[key], val) else: - base[key] = val \ No newline at end of file + base[key] = val + + +def save_config(cfg: dict, path: Path = DEFAULT_CONFIG_PATH) -> bool: + """Save config dict to YAML file (preserves existing keys, overwrites in-memory state). + + Returns True on success, False on failure. + """ + try: + import yaml + with open(path, "w") as f: + yaml.dump(cfg, f, default_flow_style=False) + logger.info("Saved config to %s", path) + return True + except (ImportError, OSError) as e: + logger.warning("Failed to save config to %s: %s", path, e) + return False \ No newline at end of file