Fix robustness issue: empty JSON {} in cfg.json or wsec.json (#355)
* Treat empty or effectively-empty configuration files as invalid: restore defaults, optionally fall back to stored settings, and avoid silently using blank configurations. * Improve presets handling by detecting and recreating empty or undersized preset files so presets are reliably initialized and usable. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: softhack007 <91616163+softhack007@users.noreply.github.com>
This commit is contained in:
@@ -223,7 +223,7 @@ bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint
|
||||
uint32_t pos = 0;
|
||||
if (!f) return false;
|
||||
|
||||
if (f.size() < 3) {
|
||||
if (f.size() < 4) { // file uninitialized -> write minimal skeleton
|
||||
char init[12];
|
||||
strcpy_P(init, PSTR("{\"0\":{}}"));
|
||||
f.print(init);
|
||||
|
||||
Reference in New Issue
Block a user