mirror of https://github.com/M66B/FairEmail.git
Service boot transaction
This commit is contained in:
parent
5abca1603a
commit
54f1948886
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue