From 8d49b25c6a8427fec8fbe2b83820801c7ea8ee0c Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 2 Aug 2018 14:40:01 +0000 Subject: [PATCH] Handle message removed exception --- .../java/eu/faircode/email/ServiceSynchronize.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 162c3ba8..92d90c00 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -63,6 +63,7 @@ import javax.mail.FetchProfile; import javax.mail.Flags; import javax.mail.Folder; import javax.mail.Message; +import javax.mail.MessageRemovedException; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; @@ -392,6 +393,8 @@ public class ServiceSynchronize extends LifecycleService { Log.i(Helper.TAG, folder.name + " messages added"); for (Message imessage : e.getMessages()) synchronizeMessage(folder, ffolder, (IMAPMessage) imessage); + } catch (MessageRemovedException ex) { + Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); } catch (Throwable ex) { Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); nm.notify("error", folder.id.intValue(), getNotification(folder.name, ex).build()); @@ -441,6 +444,8 @@ public class ServiceSynchronize extends LifecycleService { try { Log.i(Helper.TAG, folder.name + " message changed"); synchronizeMessage(folder, ffolder, (IMAPMessage) e.getMessage()); + } catch (MessageRemovedException ex) { + Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); } catch (Throwable ex) { Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); nm.notify("error", folder.id.intValue(), getNotification(folder.name, ex).build()); @@ -812,7 +817,11 @@ public class ServiceSynchronize extends LifecycleService { try { db.beginTransaction(); for (int i = 0; i < FETCH_BATCH_SIZE && batch + i < added.size(); i++) - synchronizeMessage(folder, ifolder, (IMAPMessage) added.get(batch + i)); + try { + synchronizeMessage(folder, ifolder, (IMAPMessage) added.get(batch + i)); + } catch (MessageRemovedException ex) { + Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); + } db.setTransactionSuccessful(); } finally { db.endTransaction();