Service boot transaction

This commit is contained in:
M66B 2020-01-24 08:52:04 +01:00
parent 5abca1603a
commit 54f1948886
1 changed files with 21 additions and 14 deletions

View File

@ -1566,24 +1566,31 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
public void run() { public void run() {
try { try {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try {
db.beginTransaction();
// Reset accounts // Reset accounts
for (EntityAccount account : db.account().getAccounts()) for (EntityAccount account : db.account().getAccounts())
db.account().setAccountState(account.id, null); db.account().setAccountState(account.id, null);
// reset folders // reset folders
for (EntityFolder folder : db.folder().getFolders()) { for (EntityFolder folder : db.folder().getFolders()) {
db.folder().setFolderState(folder.id, null); db.folder().setFolderState(folder.id, null);
db.folder().setFolderSyncState(folder.id, null); db.folder().setFolderSyncState(folder.id, null);
}
// Restore notifications
db.message().clearNotifyingMessages();
// Restore snooze timers
for (EntityMessage message : db.message().getSnoozed())
EntityMessage.snooze(context, message.id, message.ui_snoozed);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
} }
// Restore notifications
db.message().clearNotifyingMessages();
// Restore snooze timers
for (EntityMessage message : db.message().getSnoozed())
EntityMessage.snooze(context, message.id, message.ui_snoozed);
// Restore schedule // Restore schedule
schedule(context); schedule(context);