From 9c77f3ea430d7807c1d57991daf50b316a663456 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 12 Jan 2021 10:37:54 +0100 Subject: [PATCH] Unrecoverable sends will not be retried --- .../java/eu/faircode/email/ServiceSend.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index f4e0f61fd0..648f087a83 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -389,27 +389,29 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar Log.e(outbox.name, ex); EntityLog.log(this, "Send " + Log.formatThrowable(ex, false)); + boolean unrecoverable = (op.tries >= RETRY_MAX || + ex instanceof OutOfMemoryError || + ex instanceof MessageRemovedException || + ex instanceof FileNotFoundException || + (ex instanceof AuthenticationFailedException && !ConnectionHelper.isIoError(ex)) || + ex instanceof SendFailedException || + ex instanceof IllegalArgumentException); + db.operation().setOperationError(op.id, Log.formatThrowable(ex)); if (message != null) { db.message().setMessageError(message.id, Log.formatThrowable(ex)); try { + int tries_left = (unrecoverable ? 0 : RETRY_MAX - op.tries); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify("send:" + message.id, 1, getNotificationError( - MessageHelper.formatAddressesShort(message.to), ex, RETRY_MAX - op.tries).build()); + MessageHelper.formatAddressesShort(message.to), ex, tries_left).build()); } catch (Throwable ex1) { Log.w(ex1); } } - if (op.tries >= RETRY_MAX || - ex instanceof OutOfMemoryError || - ex instanceof MessageRemovedException || - ex instanceof FileNotFoundException || - (ex instanceof AuthenticationFailedException && - !ConnectionHelper.isIoError(ex)) || - ex instanceof SendFailedException || - ex instanceof IllegalArgumentException) { + if (unrecoverable) { Log.w("Unrecoverable"); db.operation().deleteOperation(op.id); ops.remove(op);