From 1f4a09b4df93d3820283d8263b9f2c236baf307f Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 23 Apr 2021 21:33:03 +0200 Subject: [PATCH] Delete orphan drafts --- app/src/main/java/eu/faircode/email/Core.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 44626334be..62bbd2a360 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -644,11 +644,16 @@ class Core { if (TextUtils.isEmpty(message.msgid)) throw new IllegalArgumentException("Message without msgid for " + op.name); - Long uid = findUid(context, ifolder, message.msgid, false); - if (uid == null) - throw new IllegalArgumentException("Message not found for " + op.name + " folder=" + folder.name); - DB db = DB.getInstance(context); + + Long uid = findUid(context, ifolder, message.msgid, false); + if (uid == null) { + if (EntityFolder.DRAFTS.equals(folder.type) && + EntityOperation.MOVE.equals(op.name)) + db.message().deleteMessage(message.id); + throw new IllegalArgumentException("Message not found for " + op.name + " folder=" + folder.name); + } + db.message().setMessageUid(message.id, message.uid); message.uid = uid; }