diff --git a/app/src/main/java/eu/faircode/email/EntityAttachment.java b/app/src/main/java/eu/faircode/email/EntityAttachment.java index a5a1403b48..b81926aa03 100644 --- a/app/src/main/java/eu/faircode/email/EntityAttachment.java +++ b/app/src/main/java/eu/faircode/email/EntityAttachment.java @@ -119,10 +119,13 @@ public class EntityAttachment { static void copy(Context context, long oldid, long newid) { DB db = DB.getInstance(context); + List attachments = db.attachment().getAttachments(oldid); for (EntityAttachment attachment : attachments) { File source = attachment.getFile(context); + long aid = attachment.id; + attachment.id = null; attachment.message = newid; attachment.progress = null; @@ -134,6 +137,7 @@ public class EntityAttachment { Helper.copy(source, target); } catch (IOException ex) { Log.e(ex); + db.attachment().setError(aid, Helper.formatThrowable(ex, false)); db.attachment().setError(attachment.id, Helper.formatThrowable(ex, false)); } }