mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-02 19:10:11 +01:00
Workaround server bugs
This commit is contained in:
@@ -1106,31 +1106,13 @@ public class MessageHelper {
|
||||
EntityAttachment attachment;
|
||||
}
|
||||
|
||||
MessageParts getMessageParts() throws IOException, FolderClosedException {
|
||||
MessageParts getMessageParts() throws IOException, MessagingException {
|
||||
MessageParts parts = new MessageParts();
|
||||
|
||||
MimeMessage cmessage = imessage;
|
||||
try {
|
||||
// Load body structure
|
||||
cmessage.getContentID();
|
||||
} catch (MessagingException ex) {
|
||||
// https://javaee.github.io/javamail/FAQ#imapserverbug
|
||||
if ("Unable to load BODYSTRUCTURE".equals(ex.getMessage())) {
|
||||
Log.w(ex);
|
||||
parts.warnings.add(Helper.formatThrowable(ex, false));
|
||||
try {
|
||||
cmessage = new MimeMessage(imessage);
|
||||
} catch (MessagingException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getMessageParts(cmessage, parts, false);
|
||||
|
||||
getMessageParts(imessage, parts, false);
|
||||
return parts;
|
||||
}
|
||||
|
||||
private void getMessageParts(Part part, MessageParts parts, boolean pgp) throws IOException, FolderClosedException {
|
||||
private void getMessageParts(Part part, MessageParts parts, boolean pgp) throws IOException, MessagingException {
|
||||
try {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.i("Part class=" + part.getClass() + " type=" + part.getContentType());
|
||||
@@ -1272,11 +1254,18 @@ public class MessageHelper {
|
||||
} catch (FolderClosedException ex) {
|
||||
throw ex;
|
||||
} catch (MessagingException ex) {
|
||||
if (retryRaw(ex))
|
||||
throw ex;
|
||||
Log.w(ex);
|
||||
parts.warnings.add(Helper.formatThrowable(ex, false));
|
||||
}
|
||||
}
|
||||
|
||||
static boolean retryRaw(MessagingException ex) {
|
||||
return ("Failed to load IMAP envelope".equals(ex.getMessage()) ||
|
||||
"Unable to load BODYSTRUCTURE".equals(ex.getMessage()));
|
||||
}
|
||||
|
||||
static boolean equal(Address[] a1, Address[] a2) {
|
||||
if (a1 == null && a2 == null)
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user