Fixed writeAllConfigs.
Ignore changes if value does not change.
This commit is contained in:
parent
30a30b30de
commit
f4fbd95183
|
@ -128,11 +128,10 @@ void Config::loadFile(const char *filename, const char * const sectionConfigItem
|
|||
}
|
||||
|
||||
void Config::writeAllConfigs(void) {
|
||||
boolean allChangesWritten = false;
|
||||
logHeap();
|
||||
|
||||
while (!allChangesWritten) {
|
||||
debug.out(F("Write all changed configs, checking ")); debug.out(numberOfConfigItems); debug.outln(F(" items."));
|
||||
for (int i=0; i<numberOfConfigItems; ++i) {
|
||||
debug.out("["); debug.out(i); debug.out("] ");
|
||||
debug.out(configItems[i].section);
|
||||
debug.out(".");
|
||||
debug.out(configItems[i].name);
|
||||
|
@ -142,12 +141,9 @@ void Config::writeAllConfigs(void) {
|
|||
debug.outln(configItems[i].value);
|
||||
if (configItems[i].changed) {
|
||||
writeConfigFile(configItems[i].section);
|
||||
break; // leave for-loop and restart search for changes
|
||||
}
|
||||
}
|
||||
// no further changes found, we are done
|
||||
allChangesWritten = true;
|
||||
}
|
||||
logHeap();
|
||||
}
|
||||
|
||||
void Config::writeConfigFile(String filename) {
|
||||
|
@ -229,9 +225,11 @@ void Config::setString(String key, String value) {
|
|||
debug.out(F("ERROR: Tried to set new value, but cannot find config item ")); debug.outln(key);
|
||||
} else {
|
||||
// debug.outln(configItems[index].value);
|
||||
if (!configItems[index].value.equals(value)) {
|
||||
configItems[index].value = String(value);
|
||||
configItems[index].changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue