diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 3d1a060641..6c8b7d3541 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1646,7 +1646,6 @@ class Core { DB db = DB.getInstance(context); long id = jargs.getLong(0); - Long related = (jargs.length() > 1 ? jargs.getLong(1) : null); // Get attachment EntityAttachment attachment = db.attachment().getAttachment(id); @@ -1669,7 +1668,7 @@ class Core { MessageHelper.MessageParts parts = helper.getMessageParts(); // Download attachment - parts.downloadAttachment(context, attachment, related); + parts.downloadAttachment(context, attachment); if (attachment.size != null) EntityLog.log(context, "Operation attachment size=" + attachment.size); @@ -2415,7 +2414,7 @@ class Core { for (EntityAttachment attachment : parts.getAttachments()) if (attachment.subsequence == null) - parts.downloadAttachment(context, attachment, null); + parts.downloadAttachment(context, attachment); updateContactInfo(context, account, folder, message); @@ -3753,7 +3752,7 @@ class Core { if (state.getNetworkState().isUnmetered() || (attachment.size != null && attachment.size < maxSize)) try { - parts.downloadAttachment(context, attachment, null); + parts.downloadAttachment(context, attachment); if (stats != null && attachment.size != null) stats.attachments += attachment.size; } catch (Throwable ex) { diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index ffa2b3275a..90a0cf6d68 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -6288,7 +6288,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. remote.sequence = index + 1; remote.id = db.attachment().insertAttachment(remote); try { - parts.downloadAttachment(context, index, remote, null); + parts.downloadAttachment(context, index, remote); } catch (Throwable ex) { Log.e(ex); } @@ -6931,7 +6931,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. remote.sequence = index + 1; remote.id = db.attachment().insertAttachment(remote); try { - parts.downloadAttachment(context, index, remote, null); + parts.downloadAttachment(context, index, remote); } catch (Throwable ex) { Log.e(ex); } diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index e1af380eeb..29ff9eda86 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -2022,7 +2022,7 @@ public class MessageHelper { return null; } - void downloadAttachment(Context context, EntityAttachment local, Long related) throws IOException, MessagingException { + void downloadAttachment(Context context, EntityAttachment local) throws IOException, MessagingException { List remotes = getAttachments(); // Some servers order attachments randomly @@ -2084,13 +2084,13 @@ public class MessageHelper { if (index < 0) throw new IllegalArgumentException("Attachment not found"); - downloadAttachment(context, index, local, related); + downloadAttachment(context, index, local); if (Helper.isTnef(local.type, local.name)) decodeTNEF(context, local); } - void downloadAttachment(Context context, int index, EntityAttachment local, Long related) throws MessagingException, IOException { + void downloadAttachment(Context context, int index, EntityAttachment local) throws MessagingException, IOException { Log.i("downloading attachment id=" + local.id + " index=" + index + " " + local); DB db = DB.getInstance(context); @@ -2101,8 +2101,6 @@ public class MessageHelper { // Download attachment File file = EntityAttachment.getFile(context, local.id, local.name); db.attachment().setProgress(local.id, 0); - if (related != null) - db.attachment().setProgress(related, 0); if (EntityAttachment.PGP_CONTENT.equals(apart.encrypt) || EntityAttachment.SMIME_CONTENT.equals(apart.encrypt)) { @@ -2143,10 +2141,7 @@ public class MessageHelper { long now = System.currentTimeMillis(); if (now - lastprogress > ATTACHMENT_PROGRESS_UPDATE) { lastprogress = now; - int progress = (int) (size * 100 / total); - db.attachment().setProgress(local.id, progress); - if (related != null) - db.attachment().setProgress(related, progress); + db.attachment().setProgress(local.id, (int) (size * 100 / total)); } } } @@ -2154,11 +2149,6 @@ public class MessageHelper { // Store attachment data db.attachment().setDownloaded(local.id, size); - if (related != null) { - File rel = EntityAttachment.getFile(context, related, local.name); - Helper.copy(file, rel); - db.attachment().setDownloaded(related, size); - } Log.i("Downloaded attachment size=" + size); } catch (FolderClosedIOException ex) {