Handle the case where settings2 is missing, can't migrate from 3 -> 4

This commit is contained in:
Mike Dilger 2023-08-21 14:38:15 +12:00
parent f340f24dc1
commit 886d4d5281

View File

@ -289,7 +289,18 @@ impl Storage {
Ok(())
} else {
Err(ErrorKind::General("Settings missing.".to_string()).into())
if Self::MAX_MIGRATION_LEVEL <= 4 {
// At migraiton level < 4 we know this is safe to do:
let settings = crate::settings::Settings::default();
settings.save()?;
crate::globals::GLOBALS.status_queue.write().write(
"Settings missing or corrupted. We had to reset to defaults. Sorry about that."
.to_owned(),
);
Ok(())
} else {
Err(ErrorKind::General("Settings missing.".to_string()).into())
}
}
}
}