From c6d38bf0323be13bdeb9f7487e2e53b6a285b70e Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 25 Jan 2020 18:48:06 +0100 Subject: [PATCH] Queue fetch for message added/remove in transaction --- .../eu/faircode/email/ServiceSynchronize.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 0823b35465..c9d76d1878 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1004,9 +1004,17 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences wlMessage.acquire(); Log.i(folder.name + " messages added"); - for (Message imessage : e.getMessages()) { - long uid = ifolder.getUID(imessage); - EntityOperation.queue(ServiceSynchronize.this, folder, EntityOperation.FETCH, uid); + try { + db.beginTransaction(); + + for (Message imessage : e.getMessages()) { + long uid = ifolder.getUID(imessage); + EntityOperation.queue(ServiceSynchronize.this, folder, EntityOperation.FETCH, uid); + } + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); } } catch (Throwable ex) { Log.e(folder.name, ex); @@ -1025,9 +1033,17 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences wlMessage.acquire(); Log.i(folder.name + " messages removed"); - for (Message imessage : e.getMessages()) { - long uid = ifolder.getUID(imessage); - EntityOperation.queue(ServiceSynchronize.this, folder, EntityOperation.FETCH, uid); + try { + db.beginTransaction(); + + for (Message imessage : e.getMessages()) { + long uid = ifolder.getUID(imessage); + EntityOperation.queue(ServiceSynchronize.this, folder, EntityOperation.FETCH, uid); + } + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); } } catch (Throwable ex) { Log.e(folder.name, ex);