mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-06 09:03:56 +02:00
Consistently use database transactions
To prevent hard to find problem
This commit is contained in:
@@ -157,15 +157,24 @@ public class FragmentSetup extends FragmentEx {
|
||||
@Override
|
||||
protected Void onLoad(Context context, Bundle args) throws Throwable {
|
||||
DB db = DB.getInstance(context);
|
||||
EntityFolder outbox = db.folder().getOutbox();
|
||||
if (outbox == null) {
|
||||
outbox = new EntityFolder();
|
||||
outbox.name = "OUTBOX";
|
||||
outbox.type = EntityFolder.OUTBOX;
|
||||
outbox.synchronize = false;
|
||||
outbox.after = 0;
|
||||
outbox.id = db.folder().insertFolder(outbox);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
EntityFolder outbox = db.folder().getOutbox();
|
||||
if (outbox == null) {
|
||||
outbox = new EntityFolder();
|
||||
outbox.name = "OUTBOX";
|
||||
outbox.type = EntityFolder.OUTBOX;
|
||||
outbox.synchronize = false;
|
||||
outbox.after = 0;
|
||||
outbox.id = db.folder().insertFolder(outbox);
|
||||
}
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user