fix: possible crash

This commit is contained in:
AlexeyZavar 2024-03-13 16:34:39 +03:00
parent 2414e51a9b
commit 0e26b39faf

View file

@ -153,14 +153,20 @@ void moveCurrentDatabase() {
} }
void initialize() { void initialize() {
const auto res = storage.sync_schema_simulate(true);
auto movePrevious = false; auto movePrevious = false;
try {
const auto res = storage.sync_schema_simulate(true);
for (const auto val : res | std::views::values) { for (const auto val : res | std::views::values) {
if (val == sync_schema_result::dropped_and_recreated) { if (val == sync_schema_result::dropped_and_recreated) {
movePrevious = true; movePrevious = true;
break; break;
} }
} }
} catch (...) {
LOG(("Exception during sync simulation; possibly corrupted database"));
movePrevious = true;
}
if (movePrevious) { if (movePrevious) {
moveCurrentDatabase(); moveCurrentDatabase();