diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-07-31 17:59:03 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-07-31 17:59:03 +0200 |
commit | 760f6757923c9aba2ecd7d89fc0ddfd43a741c6d (patch) | |
tree | 01ea70f1766bf08373c2fdcde8c685dd8fbddce4 /src/Cache.cpp | |
parent | Fix C&P error for DeviceType (diff) | |
download | nheko-760f6757923c9aba2ecd7d89fc0ddfd43a741c6d.tar.xz |
Ensure the encrypted rooms db is always created
Diffstat (limited to 'src/Cache.cpp')
-rw-r--r-- | src/Cache.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp index 4c24a712..7d0b1a89 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -288,6 +288,9 @@ Cache::setup() outboundMegolmSessionDb_ = lmdb::dbi::open(txn, OUTBOUND_MEGOLM_SESSIONS_DB, MDB_CREATE); megolmSessionDataDb_ = lmdb::dbi::open(txn, MEGOLM_SESSIONS_DATA_DB, MDB_CREATE); + // What rooms are encrypted + encryptedRooms_ = lmdb::dbi::open(txn, ENCRYPTED_ROOMS_DB, MDB_CREATE); + txn.commit(); databaseReady_ = true; @@ -298,8 +301,7 @@ Cache::setEncryptedRoom(lmdb::txn &txn, const std::string &room_id) { nhlog::db()->info("mark room {} as encrypted", room_id); - auto db = lmdb::dbi::open(txn, ENCRYPTED_ROOMS_DB, MDB_CREATE); - db.put(txn, room_id, "0"); + encryptedRooms_.put(txn, room_id, "0"); } bool @@ -308,8 +310,7 @@ Cache::isRoomEncrypted(const std::string &room_id) std::string_view unused; auto txn = ro_txn(env_); - auto db = lmdb::dbi::open(txn, ENCRYPTED_ROOMS_DB, MDB_CREATE); - auto res = db.get(txn, room_id, unused); + auto res = encryptedRooms_.get(txn, room_id, unused); return res; } |