diff --git a/src/Cache.cpp b/src/Cache.cpp index 44f2ecb0..536a1f32 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -34,6 +34,7 @@ #include "UserSettingsPage.h" #include "Utils.h" #include "encryption/Olm.h" +#include //! 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 &) // } } + 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(), j.dump()); + try { + accountDataDb.put(txn, j["type"].get(), 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);