mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +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;
|
||||
|
||||
UserKeyCache cacheEntry;
|
||||
UserKeyCache cacheEntry{};
|
||||
auto res = db.get(txn, user, oldKeys);
|
||||
if (res) {
|
||||
cacheEntry = nlohmann::json::parse(std::string_view(oldKeys.data(), oldKeys.size()))
|
||||
.get<UserKeyCache>();
|
||||
try {
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue