From e0ad3c46385945ff2754efdbacd463de244b9fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20M=C3=B6hle?= <91616163+softhack007@users.noreply.github.com> Date: Sun, 5 Apr 2026 22:01:33 +0200 Subject: [PATCH] robustness improvement: rewind file before writing empty JSON skeleton prevents creating corrupted JSON if the previous file content was ``{}``, the result would be ``{"0":{}}`` if the file position is not reset first. --- wled00/file.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wled00/file.cpp b/wled00/file.cpp index 2480f110..2e75217c 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -226,6 +226,7 @@ bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint if (f.size() < 4) { // file uninitialized -> write minimal skeleton char init[12]; strcpy_P(init, PSTR("{\"0\":{}}")); + f.seek(0, SeekSet); // rewind to ensure we overwrite from the start f.print(init); }