fixed a bug on the config & now backend does use config values

This commit is contained in:
2026-01-01 18:12:27 +01:00
parent 01ae038a8b
commit 74f6c9bf62
5 changed files with 54 additions and 15 deletions

View File

@@ -55,18 +55,31 @@ export function getConfig() {
};
}
function sanitizeLoadedConfig(loaded) {
return {
library: loaded.library,
paths: loaded.paths
};
}
export function setConfig(partialConfig) {
ensureConfigFile();
const current = getConfig();
const next = deepMerge(current, partialConfig);
const raw = fs.readFileSync(CONFIG_PATH, 'utf8');
const loadedRaw = yaml.load(raw) || {};
const loaded = sanitizeLoadedConfig(loadedRaw);
fs.writeFileSync(
CONFIG_PATH,
yaml.dump(next),
'utf8'
const next = deepMerge(
structuredClone(DEFAULT_CONFIG),
deepMerge(loaded, partialConfig)
);
const toSave = {
library: next.library,
paths: next.paths
};
fs.writeFileSync(CONFIG_PATH, yaml.dump(toSave), 'utf8');
return next;
}