[CFG] End preferences when key not found (#1640)

This commit is contained in:
Florian authored and GitHub committed 2023-05-11 12:53:36 -05:00
1 parent b1667190d5
commit e640c8342a
3 files changed
+13 -1

No files matched your search

+6
View File
@@ -51,6 +51,9 @@ void ONOFFConfig_fromJson(JsonObject& ONOFFdata) {
preferences.end();
Log.notice(F("ONOFF config erased" CR));
return; // Erase prevails on save, so skipping save
} else {
Log.notice(F("ONOFF config not found" CR));
preferences.end();
}
}
if (ONOFFdata.containsKey("save") && ONOFFdata["save"].as<bool>()) {
@@ -85,6 +88,9 @@ void ONOFFConfig_load() {
JsonObject jo = jsonBuffer.as<JsonObject>();
ONOFFConfig_fromJson(jo);
Log.notice(F("ONOFF config loaded" CR));
} else {
preferences.end();
Log.notice(F("ONOFF config not found" CR));
}
}
# else