Run daily job in transaction

This commit is contained in:
M66B 2018-10-24 09:29:17 +00:00
parent 688a661c5d
commit 88c034b610
1 changed files with 39 additions and 30 deletions

View File

@ -61,6 +61,9 @@ public class JobDaily extends JobService {
executor.submit(new Runnable() {
@Override
public void run() {
try {
db.beginTransaction();
Log.i(Helper.TAG, "Start daily job");
// Cleanup message files
@ -96,8 +99,14 @@ public class JobDaily extends JobService {
int logs = db.log().deleteLogs(before);
Log.i(Helper.TAG, "Deleted logs=" + logs);
db.setTransactionSuccessful();
} catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
} finally {
db.endTransaction();
Log.i(Helper.TAG, "End daily job");
}
}
});
return false;