diff --git a/app/src/main/java/eu/faircode/email/DaoAttachment.java b/app/src/main/java/eu/faircode/email/DaoAttachment.java index d13c79421a..ef9d9b7d5e 100644 --- a/app/src/main/java/eu/faircode/email/DaoAttachment.java +++ b/app/src/main/java/eu/faircode/email/DaoAttachment.java @@ -140,6 +140,6 @@ public interface DaoAttachment { @Query("DELETE FROM attachment" + " WHERE message = :message" + - " AND encryption IS NULL") - int deleteAttachments(long message); + " AND (encryption IS NULL OR encryption NOT IN (:keep))") + int deleteAttachments(long message, int[] keep); } diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 2facf235ba..eb872ef887 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -5959,7 +5959,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. Helper.writeText(file, null); db.message().setMessageContent(message.id, true, null, null, null, null); //db.message().setMessageSubject(id, subject); - db.attachment().deleteAttachments(message.id); + db.attachment().deleteAttachments(message.id, new int[]{ + EntityAttachment.PGP_MESSAGE, + EntityAttachment.SMIME_MESSAGE, + EntityAttachment.SMIME_SIGNED_DATA + }); db.message().setMessageEncrypt(message.id, message.ui_encrypt); db.message().setMessageStored(message.id, new Date().getTime()); @@ -6825,14 +6829,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. message.warning); // Remove existing attachments - db.attachment().deleteAttachments(message.id); + db.attachment().deleteAttachments(message.id, new int[]{EntityAttachment.PGP_MESSAGE}); // Add decrypted attachments List remotes = parts.getAttachments(); for (int index = 0; index < remotes.size(); index++) { EntityAttachment remote = remotes.get(index); - if (remote.encryption != null) - continue; remote.message = message.id; remote.sequence = index + 1; remote.id = db.attachment().insertAttachment(remote); @@ -7486,7 +7488,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. message.warning); // Remove existing attachments - db.attachment().deleteAttachments(message.id); + db.attachment().deleteAttachments(message.id, new int[]{ + EntityAttachment.SMIME_MESSAGE, + EntityAttachment.SMIME_SIGNED_DATA + }); // Add decrypted attachments List remotes = parts.getAttachments();