1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 17:57:16 +00:00

Cleanup/transaction

This commit is contained in:
M66B 2021-01-20 18:22:58 +01:00
parent 14a46a3025
commit 0e8c016713

View file

@ -295,16 +295,28 @@ public class WorkerCleanup extends Worker {
}
Log.i("Cleanup contacts");
int contacts = db.contact().deleteContacts(now - KEEP_CONTACTS_DURATION);
Log.i("Deleted contacts=" + contacts);
try {
db.beginTransaction();
int contacts = db.contact().deleteContacts(now - KEEP_CONTACTS_DURATION);
db.setTransactionSuccessful();
Log.i("Deleted contacts=" + contacts);
} finally {
db.endTransaction();
}
Log.i("Cleanup log");
long before = now - KEEP_LOG_DURATION;
while (true) {
int logs = db.log().deleteLogs(before, LOG_DELETE_BATCH_SIZE);
Log.i("Deleted logs=" + logs + " before=" + new Date(before));
if (logs < LOG_DELETE_BATCH_SIZE)
break;
try {
db.beginTransaction();
int logs = db.log().deleteLogs(before, LOG_DELETE_BATCH_SIZE);
db.setTransactionSuccessful();
Log.i("Deleted logs=" + logs + " before=" + new Date(before));
if (logs < LOG_DELETE_BATCH_SIZE)
break;
} finally {
db.endTransaction();
}
}
if (BuildConfig.DEBUG) {