diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 71e7494624..1102bbd32d 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1923,7 +1923,7 @@ class Core { Log.w(folder.name + " " + ex.getMessage()); Log.i(folder.name + " fetching raw message uid=" + uid); - File file = File.createTempFile("serverbug", "." + uid, context.getCacheDir()); + File file = File.createTempFile("serverbug." + folder.id, "." + uid, context.getCacheDir()); try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { imessage.writeTo(os); } @@ -1933,7 +1933,7 @@ class Core { Log.i(folder.name + " decoding again uid=" + uid); try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { - imessage = new MimeMessage(isession, is); + imessage = new MimeMessageEx(isession, is, imessage); } file.delete(); diff --git a/app/src/main/java/eu/faircode/email/MimeMessageEx.java b/app/src/main/java/eu/faircode/email/MimeMessageEx.java index 8b8abb3eea..046567b8ba 100644 --- a/app/src/main/java/eu/faircode/email/MimeMessageEx.java +++ b/app/src/main/java/eu/faircode/email/MimeMessageEx.java @@ -19,18 +19,27 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import java.io.InputStream; + +import javax.mail.Flags; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.MimeMessage; public class MimeMessageEx extends MimeMessage { private String msgid; + private MimeMessage original; MimeMessageEx(Session session, String msgid) { super(session); this.msgid = msgid; } + MimeMessageEx(Session session, InputStream is, MimeMessage original) throws MessagingException { + super(session, is); + this.original = original; + } + @Override public String getMessageID() throws MessagingException { if (this.msgid == null) @@ -48,4 +57,12 @@ public class MimeMessageEx extends MimeMessage { Log.i("Override Message-ID=" + msgid); } } + + @Override + public synchronized boolean isSet(Flags.Flag flag) throws MessagingException { + if (original == null) + return super.isSet(flag); + else + return original.isSet(flag); + } }