From 0ff2c5a45da9bb0eed3ff9847e7366715db83b8a Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 24 Aug 2019 09:38:11 +0200 Subject: [PATCH] Check delete flag on sync --- app/src/main/java/eu/faircode/email/Core.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index a285a44c0e..84799e66b5 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -44,6 +44,7 @@ import com.sun.mail.iap.Response; import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPMessage; import com.sun.mail.imap.IMAPStore; +import com.sun.mail.imap.protocol.FLAGS; import com.sun.mail.imap.protocol.FetchResponse; import com.sun.mail.imap.protocol.IMAPProtocol; import com.sun.mail.imap.protocol.UID; @@ -1115,7 +1116,8 @@ class Core { for (int i = 0; i < imessages.length && state.isRunning() && state.isRecoverable(); i++) try { - uids.remove(ifolder.getUID(imessages[i])); + if (!imessages[i].isSet(Flags.Flag.DELETED)) + uids.remove(ifolder.getUID(imessages[i])); } catch (MessageRemovedException ex) { Log.w(folder.name, ex); } catch (Throwable ex) { @@ -1165,14 +1167,15 @@ class Core { else sb.append(range.first).append(':').append(range.second); } - Response[] responses = protocol.command("UID FETCH " + sb + " (UID)", null); + Response[] responses = protocol.command("UID FETCH " + sb + " (UID FLAGS)", null); if (responses.length > 0 && responses[responses.length - 1].isOK()) { for (Response response : responses) if (response instanceof FetchResponse) { FetchResponse fr = (FetchResponse) response; UID uid = fr.getItem(UID.class); - if (uid != null) + FLAGS flags = fr.getItem(FLAGS.class); + if (uid != null && (flags == null || !flags.contains(Flags.Flag.DELETED))) uids.remove(uid.uid); } } else {