mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Fix crash on empty user cache stored
This commit is contained in:
parent
7ebf43ce38
commit
7198cee85e
1 changed files with 7 additions and 3 deletions
|
@ -4442,11 +4442,15 @@ Cache::markUserKeysOutOfDate(lmdb::txn &txn,
|
||||||
|
|
||||||
std::string_view oldKeys;
|
std::string_view oldKeys;
|
||||||
|
|
||||||
UserKeyCache cacheEntry;
|
UserKeyCache cacheEntry{};
|
||||||
auto res = db.get(txn, user, oldKeys);
|
auto res = db.get(txn, user, oldKeys);
|
||||||
if (res) {
|
if (res) {
|
||||||
cacheEntry = nlohmann::json::parse(std::string_view(oldKeys.data(), oldKeys.size()))
|
try {
|
||||||
.get<UserKeyCache>();
|
cacheEntry = nlohmann::json::parse(std::string_view(oldKeys.data(), oldKeys.size()))
|
||||||
|
.get<UserKeyCache>();
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
nhlog::db()->error("Failed to parse {}: {}", oldKeys, e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cacheEntry.last_changed = sync_token;
|
cacheEntry.last_changed = sync_token;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue