Attachment fixes

pull/157/head
M66B 6 years ago
parent 27bce77069
commit a3f9cd75ea

@ -1702,12 +1702,14 @@ class Core {
} }
for (EntityAttachment attachment : attachments) for (EntityAttachment attachment : attachments)
if (!attachment.available) if (!attachment.available && TextUtils.isEmpty(attachment.error))
if (state.getNetworkState().isUnmetered() || (attachment.size != null && attachment.size < maxSize)) if (state.getNetworkState().isUnmetered() ||
(attachment.size != null && attachment.size < maxSize))
try { try {
parts.downloadAttachment(context, attachment); parts.downloadAttachment(context, attachment);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
db.attachment().setError(attachment.id, Helper.formatThrowable(ex, false));
} }
} }
} }

@ -1419,6 +1419,7 @@ public class FragmentCompose extends FragmentBase {
attachment.name = (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction()) attachment.name = (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())
? "encrypted.asc" : "signature.asc"); ? "encrypted.asc" : "signature.asc");
attachment.type = "application/octet-stream"; attachment.type = "application/octet-stream";
attachment.disposition = Part.INLINE;
attachment.encryption = (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction()) attachment.encryption = (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())
? EntityAttachment.PGP_MESSAGE : EntityAttachment.PGP_SIGNATURE); ? EntityAttachment.PGP_MESSAGE : EntityAttachment.PGP_SIGNATURE);
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
@ -1779,8 +1780,7 @@ public class FragmentCompose extends FragmentBase {
attachment.type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase()); attachment.type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
if (attachment.type == null) if (attachment.type == null)
attachment.type = "application/octet-stream"; attachment.type = "application/octet-stream";
if (image) attachment.disposition = (image ? Part.INLINE : Part.ATTACHMENT);
attachment.disposition = Part.INLINE;
attachment.size = (s == null ? null : Long.parseLong(s)); attachment.size = (s == null ? null : Long.parseLong(s));
attachment.progress = 0; attachment.progress = 0;
@ -2131,6 +2131,7 @@ public class FragmentCompose extends FragmentBase {
attachment.sequence = 1; attachment.sequence = 1;
attachment.name = ics.getName(); attachment.name = ics.getName();
attachment.type = "text/calendar"; attachment.type = "text/calendar";
attachment.disposition = Part.ATTACHMENT;
attachment.size = ics.length(); attachment.size = ics.length();
attachment.progress = null; attachment.progress = null;
attachment.available = true; attachment.available = true;

@ -60,6 +60,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.mail.Address; import javax.mail.Address;
import javax.mail.Part;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
public class Log { public class Log {
@ -293,6 +294,7 @@ public class Log {
attachment.sequence = sequence; attachment.sequence = sequence;
attachment.name = "settings.txt"; attachment.name = "settings.txt";
attachment.type = "text/plain"; attachment.type = "text/plain";
attachment.disposition = Part.ATTACHMENT;
attachment.size = null; attachment.size = null;
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
@ -319,6 +321,7 @@ public class Log {
attachment.sequence = sequence; attachment.sequence = sequence;
attachment.name = "accounts.txt"; attachment.name = "accounts.txt";
attachment.type = "text/plain"; attachment.type = "text/plain";
attachment.disposition = Part.ATTACHMENT;
attachment.size = null; attachment.size = null;
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
@ -364,6 +367,7 @@ public class Log {
attachment.sequence = sequence; attachment.sequence = sequence;
attachment.name = "network.txt"; attachment.name = "network.txt";
attachment.type = "text/plain"; attachment.type = "text/plain";
attachment.disposition = Part.ATTACHMENT;
attachment.size = null; attachment.size = null;
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
@ -395,6 +399,7 @@ public class Log {
attachment.sequence = sequence; attachment.sequence = sequence;
attachment.name = "log.txt"; attachment.name = "log.txt";
attachment.type = "text/plain"; attachment.type = "text/plain";
attachment.disposition = Part.ATTACHMENT;
attachment.size = null; attachment.size = null;
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
@ -421,6 +426,7 @@ public class Log {
attachment.sequence = sequence; attachment.sequence = sequence;
attachment.name = "operations.txt"; attachment.name = "operations.txt";
attachment.type = "text/plain"; attachment.type = "text/plain";
attachment.disposition = Part.ATTACHMENT;
attachment.size = null; attachment.size = null;
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
@ -451,6 +457,7 @@ public class Log {
attachment.sequence = sequence; attachment.sequence = sequence;
attachment.name = "logcat.txt"; attachment.name = "logcat.txt";
attachment.type = "text/plain"; attachment.type = "text/plain";
attachment.disposition = Part.ATTACHMENT;
attachment.size = null; attachment.size = null;
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);

@ -864,7 +864,6 @@ public class MessageHelper {
for (int i = 0; i < remotes.size(); i++) { for (int i = 0; i < remotes.size(); i++) {
EntityAttachment remote = remotes.get(i); EntityAttachment remote = remotes.get(i);
if (Objects.equals(remote.name, local.name) && if (Objects.equals(remote.name, local.name) &&
Objects.equals(remote.disposition, local.disposition) &&
Objects.equals(remote.cid, local.cid)) { Objects.equals(remote.cid, local.cid)) {
found = true; found = true;
downloadAttachment(context, i, local); downloadAttachment(context, i, local);

Loading…
Cancel
Save