... on second thought, just bump the cfg version

This commit is contained in:
Maxim Prokhorov
2020-08-26 11:08:55 +03:00
parent 378cfdc09a
commit dc8a672e00
4 changed files with 75 additions and 63 deletions

View File

@@ -26,15 +26,27 @@ void _cmpMoveIndexDown(const char * key, int offset = 0) {
// 2: based on Embedis, with board definitions 1-based
// 3: based on Embedis, with board definitions 0-based
// 4: based on Embedis, no board definitions
// 5: based on Embedis, updated rfb codes format
int migrateVersion() {
const static auto version = getSetting("cfg", CFG_VERSION);
if (version == CFG_VERSION) {
return 0;
}
return version;
}
void migrate() {
// Update if not on the latest version
const auto version = getSetting("cfg", CFG_VERSION);
if (version == CFG_VERSION) return;
// We either get 0, when version did not change
// Or, the version we migrate from
const auto version = migrateVersion();
setSetting("cfg", CFG_VERSION);
switch (version) {
if (!version) return;
switch (migrateVersion()) {
// migrate old version with 1-based indices
case 2:
_cmpMoveIndexDown("ledGPIO");