From 9ac9b08f5f1351bdc27b85e8232dbad11544e340 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 21 Sep 2019 13:33:04 +0200 Subject: [PATCH] Workaround server bug --- .../java/eu/faircode/email/DaoAttachment.java | 4 ++++ .../java/eu/faircode/email/MessageHelper.java | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/DaoAttachment.java b/app/src/main/java/eu/faircode/email/DaoAttachment.java index 770d888811..469577cac7 100644 --- a/app/src/main/java/eu/faircode/email/DaoAttachment.java +++ b/app/src/main/java/eu/faircode/email/DaoAttachment.java @@ -23,6 +23,7 @@ import androidx.lifecycle.LiveData; import androidx.room.Dao; import androidx.room.Insert; import androidx.room.Query; +import androidx.room.Update; import java.util.List; @@ -100,6 +101,9 @@ public interface DaoAttachment { @Insert long insertAttachment(EntityAttachment attachment); + @Update + int updateAttachment(EntityAttachment attachment); + @Query("DELETE FROM attachment" + " WHERE id = :id") int deleteAttachment(long id); diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index a8d02cce05..42ffa3083c 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -990,6 +990,30 @@ public class MessageHelper { // Get data AttachmentPart apart = attachments.get(index); + if (local.name == null && apart.attachment.name != null) { + local.name = apart.attachment.name; + db.attachment().updateAttachment(local); + Log.i("Updated name " + local); + } + + if (local.disposition == null && apart.attachment.disposition != null) { + local.disposition = apart.attachment.disposition; + db.attachment().updateAttachment(local); + Log.i("Updated disposition " + local); + } + + if (local.cid == null && apart.attachment.cid != null) { + local.cid = apart.attachment.cid; + db.attachment().updateAttachment(local); + Log.i("Updated cid " + local); + } + + if (local.size == null && apart.attachment.size != null) { + local.size = apart.attachment.size; + db.attachment().updateAttachment(local); + Log.i("Updated size " + local); + } + // Download attachment File file = EntityAttachment.getFile(context, local.id, local.name); db.attachment().setProgress(local.id, null);