From e68142de47ee4cc03c8511d7d1d285aeb9f1c898 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 2 Aug 2018 16:24:23 +0000 Subject: [PATCH] Check for message removed exception --- .../eu/faircode/email/ServiceSynchronize.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 7375b713..9a97f1a2 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -419,12 +419,15 @@ public class ServiceSynchronize extends LifecycleService { public void messagesRemoved(MessageCountEvent e) { try { Log.i(Helper.TAG, folder.name + " messages removed"); - for (Message imessage : e.getMessages()) { - long uid = ffolder.getUID(imessage); - DB db = DB.getInstance(ServiceSynchronize.this); - db.message().deleteMessage(folder.id, uid); - Log.i(Helper.TAG, "Deleted uid=" + uid); - } + for (Message imessage : e.getMessages()) + try { + long uid = ffolder.getUID(imessage); + DB db = DB.getInstance(ServiceSynchronize.this); + db.message().deleteMessage(folder.id, uid); + Log.i(Helper.TAG, "Deleted uid=" + uid); + } 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)); reportError(account.name, folder.name, ex); @@ -804,10 +807,12 @@ public class ServiceSynchronize extends LifecycleService { List added = new ArrayList<>(); for (Message imessage : imessages) - if (!imessage.isExpunged() && !imessage.isSet(Flags.Flag.DELETED)) { + try { long uid = ifolder.getUID(imessage); if (!uids.remove(uid)) added.add(imessage); + } catch (MessageRemovedException ex) { + Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); } // Delete local messages not at remote @@ -845,13 +850,6 @@ public class ServiceSynchronize extends LifecycleService { fp.add(IMAPFolder.FetchProfileItem.FLAGS); ifolder.fetch(new Message[]{imessage}, fp); - boolean expunged = imessage.isExpunged(); - boolean deleted = (!expunged && imessage.isSet(Flags.Flag.DELETED)); - if (expunged || deleted) { - Log.i(Helper.TAG, "Message gone expunged=" + expunged + " deleted=" + deleted); - return; - } - long uid = ifolder.getUID(imessage); Log.i(Helper.TAG, folder.name + " sync uid=" + uid);