Classifier: cleanup msgids

This commit is contained in:
M66B 2021-01-10 17:32:14 +01:00
parent 5960ce70ef
commit 348005262b
2 changed files with 27 additions and 0 deletions

View File

@ -396,6 +396,31 @@ public class MessageClassifier {
Log.i("Classifier data loaded");
}
static synchronized void cleanup(@NonNull Context context) {
try {
load(context);
DB db = DB.getInstance(context);
for (Long account : accountMsgIds.keySet()) {
List<String> msgids = accountMsgIds.get(account);
Log.i("Classifier cleanup account=" + account + " count=" + msgids.size());
for (String msgid : new ArrayList<>(msgids)) {
List<EntityMessage> messages = db.message().getMessagesByMsgId(account, msgid);
if (messages != null && messages.size() == 0) {
Log.i("Classifier removing msgid=" + msgid);
msgids.remove(msgid);
dirty = true;
}
}
}
if (dirty)
save(context);
} catch (Throwable ex) {
Log.e(ex);
}
}
static synchronized void clear(@NonNull Context context) {
wordClassFrequency.clear();
dirty = true;

View File

@ -142,6 +142,8 @@ public class WorkerCleanup extends Worker {
ServiceSynchronize.reschedule(context);
MessageClassifier.cleanup(context);
// Contact info cache
ContactInfo.clearCache(context);