mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 10:17:18 +00:00
Cleanup/transaction
This commit is contained in:
parent
14a46a3025
commit
0e8c016713
1 changed files with 18 additions and 6 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue