summary refs log tree commit diff
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-16 11:19:18 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-16 11:19:18 +0300
commit9ad4aab657b551c107e8b437bfc8bb5b1a6757b8 (patch)
treec569874d6cc600b554020bd1d092db2c4913a70c
parentImplement import/export of megolm session keys (#358) (diff)
downloadnheko-9ad4aab657b551c107e8b437bfc8bb5b1a6757b8.tar.xz
Ignore sessions that cannot be parsed
-rw-r--r--src/Cache.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp
index cbff2ca6..feadb006 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -224,9 +224,16 @@ Cache::exportSessionKeys()
         std::string key, value;
         while (cursor.get(key, value, MDB_NEXT)) {
                 ExportedSession exported;
+                MegolmSessionIndex index;
 
                 auto saved_session = unpickle<InboundSessionObject>(value, SECRET);
-                auto index         = nlohmann::json::parse(key).get<MegolmSessionIndex>();
+
+                try {
+                        index = nlohmann::json::parse(key).get<MegolmSessionIndex>();
+                } catch (const nlohmann::json::exception &e) {
+                        nhlog::db()->critical("failed to export megolm session: {}", e.what());
+                        continue;
+                }
 
                 exported.room_id     = index.room_id;
                 exported.sender_key  = index.sender_key;