From 1647e3e652f6bd17095bc1dc322b8c186ee30ee9 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 21 Sep 2018 13:27:11 +0000 Subject: [PATCH] Handle duplicate CID --- .../main/java/eu/faircode/email/ServiceSynchronize.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 9147e4650b..ed5c06ad29 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1711,8 +1711,13 @@ public class ServiceSynchronize extends LifecycleService { int sequence = 1; for (EntityAttachment attachment : helper.getAttachments()) { - Log.i(Helper.TAG, folder.name + " attachment" + - " seq=" + sequence + " name=" + attachment.name + " type=" + attachment.type); + Log.i(Helper.TAG, folder.name + " attachment seq=" + sequence + + " name=" + attachment.name + " type=" + attachment.type + " cid=" + attachment.cid); + if (!TextUtils.isEmpty(attachment.cid) && + db.attachment().getAttachment(message.id, attachment.cid) != null) { + Log.i(Helper.TAG, "Skipping duplicated CID"); + continue; + } attachment.message = message.id; attachment.sequence = sequence++; attachment.id = db.attachment().insertAttachment(attachment);