From b7063051351d0c3c86544ed12bc024c6abfbc937 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 16 Mar 2019 09:54:10 +0000 Subject: [PATCH] Revert "Generate new ID when moving message" This reverts commit ef6ff3ecb7d450ae6737e540ce5ccea11b297a5d. --- app/src/main/java/eu/faircode/email/Core.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index a48de7ef1b..07f0290b0b 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -424,9 +424,8 @@ class Core { imessage.setFlag(Flags.Flag.DRAFT, true); // Add message - Log.i(folder.name + " ADD appending id=" + message.id); long uid = append(istore, ifolder, imessage); - Log.i(folder.name + " ADD appended id=" + message.id + " uid=" + uid); + Log.i(folder.name + " appended id=" + message.id + " uid=" + uid); db.message().setMessageUid(message.id, uid); if (folder.id.equals(message.folder)) { @@ -435,9 +434,9 @@ class Core { for (Message idelete : ideletes) { long duid = ifolder.getUID(idelete); if (duid == uid) - Log.i(folder.name + " ADD append confirmed uid=" + duid); + Log.i(folder.name + " append confirmed uid=" + duid); else { - Log.i(folder.name + " ADD deleting uid=" + duid + " msgid=" + message.msgid); + Log.i(folder.name + " deleting uid=" + duid + " msgid=" + message.msgid); idelete.setFlag(Flags.Flag.DELETED, true); } } @@ -481,6 +480,14 @@ class Core { throw new FolderNotFoundException(); IMAPFolder itarget = (IMAPFolder) istore.getFolder(target.name); + // Get message ID + String msgid; + if (copy || message.msgid == null) { + msgid = EntityMessage.generateMessageId(); + Log.i(target.name + " generated message id=" + msgid); + } else + msgid = message.msgid; + // Serialize source message ByteArrayOutputStream bos = new ByteArrayOutputStream(); imessage.writeTo(bos); @@ -508,14 +515,12 @@ class Core { if (itarget.getPermanentFlags().contains(Flags.Flag.DRAFT)) icopy.setFlag(Flags.Flag.DRAFT, true); - // Generate new ID - icopy.setHeader("Message-ID", EntityMessage.generateMessageId()); + icopy.setHeader("Message-ID", msgid); // Append target - Log.i(folder.name + " MOVE appending id=" + message.id); long uid = append(istore, itarget, (MimeMessage) icopy); if (newid != null) { - Log.i(folder.name + " MOVE moved id=" + newid + " uid=" + uid); + Log.i("Moved id=" + newid + " uid=" + uid); db.message().setMessageUid(newid, uid); }