diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 3f27eb2581..04f107da65 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1702,12 +1702,14 @@ class Core { } for (EntityAttachment attachment : attachments) - if (!attachment.available) - if (state.getNetworkState().isUnmetered() || (attachment.size != null && attachment.size < maxSize)) + if (!attachment.available && TextUtils.isEmpty(attachment.error)) + if (state.getNetworkState().isUnmetered() || + (attachment.size != null && attachment.size < maxSize)) try { parts.downloadAttachment(context, attachment); } catch (Throwable ex) { Log.e(ex); + db.attachment().setError(attachment.id, Helper.formatThrowable(ex, false)); } } } diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 11c6ecdaa7..e471e5fd7a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1419,6 +1419,7 @@ public class FragmentCompose extends FragmentBase { attachment.name = (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction()) ? "encrypted.asc" : "signature.asc"); attachment.type = "application/octet-stream"; + attachment.disposition = Part.INLINE; attachment.encryption = (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction()) ? EntityAttachment.PGP_MESSAGE : EntityAttachment.PGP_SIGNATURE); attachment.id = db.attachment().insertAttachment(attachment); @@ -1779,8 +1780,7 @@ public class FragmentCompose extends FragmentBase { attachment.type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase()); if (attachment.type == null) attachment.type = "application/octet-stream"; - if (image) - attachment.disposition = Part.INLINE; + attachment.disposition = (image ? Part.INLINE : Part.ATTACHMENT); attachment.size = (s == null ? null : Long.parseLong(s)); attachment.progress = 0; @@ -2131,6 +2131,7 @@ public class FragmentCompose extends FragmentBase { attachment.sequence = 1; attachment.name = ics.getName(); attachment.type = "text/calendar"; + attachment.disposition = Part.ATTACHMENT; attachment.size = ics.length(); attachment.progress = null; attachment.available = true; diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index 2b508a03b5..1ef269e4aa 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -60,6 +60,7 @@ import java.util.Map; import java.util.Set; import javax.mail.Address; +import javax.mail.Part; import javax.mail.internet.InternetAddress; public class Log { @@ -293,6 +294,7 @@ public class Log { attachment.sequence = sequence; attachment.name = "settings.txt"; attachment.type = "text/plain"; + attachment.disposition = Part.ATTACHMENT; attachment.size = null; attachment.progress = 0; attachment.id = db.attachment().insertAttachment(attachment); @@ -319,6 +321,7 @@ public class Log { attachment.sequence = sequence; attachment.name = "accounts.txt"; attachment.type = "text/plain"; + attachment.disposition = Part.ATTACHMENT; attachment.size = null; attachment.progress = 0; attachment.id = db.attachment().insertAttachment(attachment); @@ -364,6 +367,7 @@ public class Log { attachment.sequence = sequence; attachment.name = "network.txt"; attachment.type = "text/plain"; + attachment.disposition = Part.ATTACHMENT; attachment.size = null; attachment.progress = 0; attachment.id = db.attachment().insertAttachment(attachment); @@ -395,6 +399,7 @@ public class Log { attachment.sequence = sequence; attachment.name = "log.txt"; attachment.type = "text/plain"; + attachment.disposition = Part.ATTACHMENT; attachment.size = null; attachment.progress = 0; attachment.id = db.attachment().insertAttachment(attachment); @@ -421,6 +426,7 @@ public class Log { attachment.sequence = sequence; attachment.name = "operations.txt"; attachment.type = "text/plain"; + attachment.disposition = Part.ATTACHMENT; attachment.size = null; attachment.progress = 0; attachment.id = db.attachment().insertAttachment(attachment); @@ -451,6 +457,7 @@ public class Log { attachment.sequence = sequence; attachment.name = "logcat.txt"; attachment.type = "text/plain"; + attachment.disposition = Part.ATTACHMENT; attachment.size = null; attachment.progress = 0; attachment.id = db.attachment().insertAttachment(attachment); diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 5057a9723d..51bd78abff 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -864,7 +864,6 @@ public class MessageHelper { for (int i = 0; i < remotes.size(); i++) { EntityAttachment remote = remotes.get(i); if (Objects.equals(remote.name, local.name) && - Objects.equals(remote.disposition, local.disposition) && Objects.equals(remote.cid, local.cid)) { found = true; downloadAttachment(context, i, local);