From 12f6fbc00534cc18805e8f1eb5c4d071fca36300 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:11:00 +0200 Subject: [PATCH] robustness: Rewind file pointer before writing initial data if the presets.json file initially contains ``{}`` (valid JSON, could be created by user edit), we need to first rewind the file. Otherwise the result would be ``{}{"0":{}}`` (ivalid JSON) --- wled00/file.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wled00/file.cpp b/wled00/file.cpp index dcc2d57c4..5a169d645 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -188,6 +188,7 @@ static bool appendObjectToFile(const char* key, const JsonDocument* content, uin if (f.size() < 3) { char init[10]; strcpy_P(init, PSTR("{\"0\":{}}")); + f.seek(0, SeekSet); // rewind to ensure we overwrite from the start, instead of appending f.print(init); }