Fixed error where an invalid event would cause the entire application to halt, this just ignores it.

This commit is contained in:
Skye J 2023-05-30 17:54:46 -04:00
parent a1fed44b50
commit b5d5d1c393

View file

@ -34,6 +34,7 @@
#include "UserSettingsPage.h"
#include "Utils.h"
#include "encryption/Olm.h"
#include <typeinfo>
//! Should be changed when a breaking change occurs in the cache format.
//! This will reset client's data.
@ -1848,6 +1849,7 @@ isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallHangUp> &)
// }
}
void
Cache::saveState(const mtx::responses::Sync &res)
{
@ -1876,10 +1878,17 @@ Cache::saveState(const mtx::responses::Sync &res)
}
auto j = nlohmann::json(event);
accountDataDb.put(txn, j["type"].get<std::string>(), j.dump());
try {
accountDataDb.put(txn, j["type"].get<std::string>(), j.dump());
}
catch (const lmdb::error &e) {
nhlog::db()->warn("failed to save state after sync: {}, skipping event", e.what());
return;
}
},
ev);
}
}
auto userKeyCacheDb = getUserKeysDb(txn);