From d8dbe8b7c76649efc4d49dad434b1235501a4f76 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 5 Aug 2019 09:47:14 +0200 Subject: [PATCH] Optimized delete --- app/src/main/java/eu/faircode/email/Core.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 9cad0cb2d0..3bfdfa3ced 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -650,6 +650,8 @@ class Core { // Delete message DB db = DB.getInstance(context); + boolean deleted = false; + if (message.uid != null) { Message iexisting = ifolder.getMessageByUID(message.uid); if (iexisting == null) @@ -658,12 +660,13 @@ class Core { try { Log.i(folder.name + " deleting uid=" + message.uid); iexisting.setFlag(Flags.Flag.DELETED, true); + deleted = true; } catch (MessageRemovedException ignored) { Log.w(folder.name + " existing gone uid=" + message.uid); } } - if (!TextUtils.isEmpty(message.msgid)) { + if (!TextUtils.isEmpty(message.msgid) && !deleted) { Message[] imessages = ifolder.search(new MessageIDTerm(message.msgid)); if (imessages == null) Log.w(folder.name + " search for msgid=" + message.msgid + " returned null");