diff --git a/wled00/presets.cpp b/wled00/presets.cpp index 2ef0bfd7..996aff3b 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -312,6 +312,7 @@ void savePreset(byte index, const char* pname, JsonObject sObj) } DEBUG_PRINT(F("Saving preset (")); DEBUG_PRINT(index); DEBUG_PRINT(F(") ")); DEBUG_PRINTLN(saveName); + auto oldpresetToSave = presetToSave; // for recovery in case that esp32SemTake(presetFileMux) fails presetToSave = index; playlistSave = false; @@ -330,6 +331,7 @@ void savePreset(byte index, const char* pname, JsonObject sObj) // WLEDMM Acquire file mutex before writing presets.json, to prevent presets.json corruption if (esp32SemTake(presetFileMux, 2500) != pdTRUE) { USER_PRINTLN(F("savePreset(): preset file busy, cannot write")); + presetToSave = oldpresetToSave; return; // early exit, no change }