Only prune old messages every 500 syncs

This commit is contained in:
Nicolas Werner 2020-04-26 11:29:05 +02:00
parent 28adc9dc9b
commit d6386546b3
1 changed files with 7 additions and 1 deletions

View File

@ -1000,7 +1000,13 @@ ChatPage::trySync()
emit syncTags(cache::roomTagUpdates(res));
cache::deleteOldData();
// 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();