restore revious presetToSave in case that mutex acquisition fails
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user