mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Remove old messages only when the db is full or on startup
Adds about 40ms of startup delay here, which I think is okay.
This commit is contained in:
parent
13a540646f
commit
f8041d176a
1 changed files with 4 additions and 8 deletions
|
@ -588,6 +588,10 @@ ChatPage::loadStateFromCache()
|
|||
try {
|
||||
olm::client()->load(cache::restoreOlmAccount(), cache::client()->pickleSecret());
|
||||
|
||||
nhlog::db()->info("Removing old cached messages");
|
||||
cache::deleteOldData();
|
||||
nhlog::db()->info("Message removal done");
|
||||
|
||||
emit initializeEmptyViews();
|
||||
|
||||
cache::calculateRoomReadStatus();
|
||||
|
@ -769,14 +773,6 @@ ChatPage::handleSyncResponse(const mtx::responses::Sync &res, const std::string
|
|||
auto updates = cache::getRoomInfo(cache::client()->roomsWithStateUpdates(res));
|
||||
|
||||
emit syncUI(std::move(res));
|
||||
|
||||
// if we process a lot of syncs (1 every 200ms), this means we clean the
|
||||
// db every 100s
|
||||
static int syncCounter = 0;
|
||||
if (syncCounter++ >= 500) {
|
||||
cache::deleteOldData();
|
||||
syncCounter = 0;
|
||||
}
|
||||
} catch (const lmdb::map_full_error &e) {
|
||||
nhlog::db()->error("lmdb is full: {}", e.what());
|
||||
cache::deleteOldData();
|
||||
|
|
Loading…
Reference in a new issue