Silently ignore broken messages

pull/125/head
M66B 6 years ago
parent 17c37807bd
commit 96df682541

@ -161,11 +161,14 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
int index = imessages.length - 1;
while (index >= 0) {
if (imessages[index].getReceivedDate().getTime() < before) {
Log.i(Helper.TAG, "Boundary sync uid=" + ifolder.getUID(imessages[index]));
ServiceSynchronize.synchronizeMessage(context, folder, ifolder, (IMAPMessage) imessages[index], true);
break;
}
if (imessages[index].getReceivedDate().getTime() < before)
try {
Log.i(Helper.TAG, "Boundary sync uid=" + ifolder.getUID(imessages[index]));
ServiceSynchronize.synchronizeMessage(context, folder, ifolder, (IMAPMessage) imessages[index], true);
break;
} catch (Throwable ex) {
Log.e(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex));
}
index--;
}

@ -309,40 +309,28 @@ public class MessageHelper {
if (part.isMimeType("multipart/alternative")) {
String text = null;
try {
Multipart mp = (Multipart) part.getContent();
for (int i = 0; i < mp.getCount(); i++) {
Part bp = mp.getBodyPart(i);
if (bp.isMimeType("text/plain")) {
if (text == null)
text = getHtml(bp);
} else if (bp.isMimeType("text/html")) {
String s = getHtml(bp);
if (s != null)
return s;
} else
return getHtml(bp);
}
} catch (UnsupportedEncodingException ex) {
throw ex;
} catch (IOException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
Multipart mp = (Multipart) part.getContent();
for (int i = 0; i < mp.getCount(); i++) {
Part bp = mp.getBodyPart(i);
if (bp.isMimeType("text/plain")) {
if (text == null)
text = getHtml(bp);
} else if (bp.isMimeType("text/html")) {
String s = getHtml(bp);
if (s != null)
return s;
} else
return getHtml(bp);
}
return text;
}
if (part.isMimeType("multipart/*")) {
try {
Multipart mp = (Multipart) part.getContent();
for (int i = 0; i < mp.getCount(); i++) {
String s = getHtml(mp.getBodyPart(i));
if (s != null)
return s;
}
} catch (UnsupportedEncodingException ex) {
throw ex;
} catch (IOException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
Multipart mp = (Multipart) part.getContent();
for (int i = 0; i < mp.getCount(); i++) {
String s = getHtml(mp.getBodyPart(i));
if (s != null)
return s;
}
}
@ -381,6 +369,7 @@ public class MessageHelper {
try {
disposition = part.getDisposition();
} catch (MessagingException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
disposition = null;
}
@ -388,6 +377,7 @@ public class MessageHelper {
try {
filename = part.getFileName();
} catch (MessagingException ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
filename = null;
}

@ -104,7 +104,6 @@ import javax.mail.event.StoreEvent;
import javax.mail.event.StoreListener;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.ParseException;
import javax.mail.search.ComparisonTerm;
import javax.mail.search.ReceivedDateTerm;
import javax.net.ssl.SSLException;
@ -522,6 +521,8 @@ public class ServiceSynchronize extends LifecycleService {
synchronizeMessage(ServiceSynchronize.this, folder, ifolder, (IMAPMessage) imessage, false);
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
}
EntityOperation.process(ServiceSynchronize.this); // download small attachments
} catch (Throwable ex) {
@ -584,6 +585,8 @@ public class ServiceSynchronize extends LifecycleService {
EntityOperation.process(ServiceSynchronize.this); // download small attachments
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
}
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
@ -1281,11 +1284,10 @@ public class ServiceSynchronize extends LifecycleService {
updated++;
else
unchanged++;
} catch (ParseException ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
reportError(account.name, folder.name, ex);
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
}
EntityOperation.process(this); // download small attachments

Loading…
Cancel
Save