Skip migration if sender_key is not a string or present

This commit is contained in:
Nicolas Werner 2022-06-18 00:10:47 +02:00
parent b0e3c6d65a
commit b57152a1c9
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -1326,7 +1326,9 @@ Cache::runMigrations()
std::map<std::string, std::string> inboundSessions; std::map<std::string, std::string> inboundSessions;
std::map<std::string, std::string> megolmSessionData; std::map<std::string, std::string> megolmSessionData;
while (cursor.get(key, value, MDB_NEXT)) { while (cursor.get(key, value, MDB_NEXT)) {
auto indexVal = nlohmann::json::parse(key); auto indexVal = nlohmann::json::parse(key);
if (!indexVal.contains("sender_key") || !indexVal.at("sender_key").is_string())
continue;
auto sender_key = indexVal["sender_key"].get<std::string>(); auto sender_key = indexVal["sender_key"].get<std::string>();
indexVal.erase("sender_key"); indexVal.erase("sender_key");