feat: safely merge partial persistent updates and update hide ui script

This commit is contained in:
CAtlas0784 committed 2026-10-17 01:05:58 +07:00
1 parent 332171cafb
commit 83fa8c7d44
3 files changed
+115 -56

No files matched your search

+10 -1
View File
@@ -312,7 +312,16 @@ func apiPersistentData(w http.ResponseWriter, r *http.Request) {
return
}
out, _ := json.MarshalIndent(parsed, "", " ")
// Merge into existing persistent file so partial updates (e.g. lineups or switches) preserve other settings
existing := make(map[string]any)
if raw, err := os.ReadFile("persistent"); err == nil {
_ = json.Unmarshal(raw, &existing)
}
for k, v := range parsed {
existing[k] = v
}
out, _ := json.MarshalIndent(existing, "", " ")
if err := os.WriteFile("persistent", out, 0o644); err != nil {
writeJSON(w, map[string]any{"error": "failed to write persistent: " + err.Error(), "status": 500})
return