diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java
index 43bd42573e..46eb023f56 100644
--- a/app/src/main/java/eu/faircode/email/Core.java
+++ b/app/src/main/java/eu/faircode/email/Core.java
@@ -185,6 +185,9 @@ class Core {
DB db = DB.getInstance(context);
+ NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+
int retry = 0;
boolean group = true;
Log.i(folder.name + " executing operations=" + ops.size());
@@ -202,6 +205,10 @@ class Core {
" group=" + group +
" retry=" + retry);
+ if (EntityOperation.HEADERS.equals(op.name) ||
+ EntityOperation.RAW.equals(op.name))
+ nm.cancel(op.name + ":" + op.message, 1);
+
if (!Objects.equals(folder.id, op.folder))
throw new IllegalArgumentException("Invalid folder=" + folder.id + "/" + op.folder);
@@ -487,6 +494,7 @@ class Core {
if (message != null &&
!EntityOperation.FETCH.equals(op.name) &&
+ !EntityOperation.ATTACHMENT.equals(op.name) &&
!(ex instanceof IllegalArgumentException))
db.message().setMessageError(message.id, op.error);
@@ -512,6 +520,8 @@ class Core {
(ex.getCause() instanceof BadCommandException ||
ex.getCause() instanceof CommandFailedException /* NO */)) ||
MessageHelper.isRemoved(ex) ||
+ EntityOperation.HEADERS.equals(op.name) ||
+ EntityOperation.RAW.equals(op.name) ||
EntityOperation.ATTACHMENT.equals(op.name) ||
(EntityOperation.ADD.equals(op.name) &&
EntityFolder.DRAFTS.equals(folder.type))) {
@@ -599,6 +609,18 @@ class Core {
}
ops.remove(op);
+
+ int resid = context.getResources().getIdentifier(
+ "title_op_title_" + op.name,
+ "string",
+ context.getPackageName());
+ String title = (resid == 0 ? null : context.getString(resid));
+ if (title != null) {
+ NotificationCompat.Builder builder =
+ getNotificationError(context, "warning", title, ex);
+ nm.notify(op.name + ":" + op.message, 1, builder.build());
+ }
+
} else {
retry++;
if (retry < LOCAL_RETRY_MAX &&
diff --git a/app/src/main/java/eu/faircode/email/EntityOperation.java b/app/src/main/java/eu/faircode/email/EntityOperation.java
index bf9bbbaa88..fa7c9dd6ca 100644
--- a/app/src/main/java/eu/faircode/email/EntityOperation.java
+++ b/app/src/main/java/eu/faircode/email/EntityOperation.java
@@ -511,7 +511,9 @@ public class EntityOperation {
if (EntityOperation.ATTACHMENT.equals(name))
try {
JSONArray jargs = new JSONArray(args);
- db.attachment().setProgress(jargs.getLong(0), null);
+ long id = jargs.getLong(0);
+ db.attachment().setProgress(id, null);
+ db.attachment().setError(id, error);
return;
} catch (JSONException ex) {
Log.e(ex);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 50b510bf39..8efec24e50 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -820,6 +820,8 @@
Delete all local contacts?
No pending operations
Deleting operations can result in disappearing messages and synchronization problems
+ Downloading headers
+ Downloading raw message
Folder name
Display name