From d25bbcb5d9d6bfea236e084eac47c1a1e8c80a04 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 4 Nov 2020 11:20:54 +0100 Subject: [PATCH] No more orphans --- app/src/main/java/eu/faircode/email/Core.java | 17 +++-------------- .../main/java/eu/faircode/email/DaoMessage.java | 9 --------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index bb36d15bfd..b707c38566 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2482,20 +2482,9 @@ class Core { } } - // Add local sent messages to remote sent folder - if (EntityFolder.SENT.equals(folder.type)) { - List orphans = db.message().getOrphans(folder.id); - Log.i(folder.name + " sent orphans=" + orphans.size()); - for (EntityMessage orphan : orphans) { - Log.i(folder.name + " adding orphan id=" + orphan.id); - if (orphan.content && !orphan.ui_hide) - EntityOperation.queue(context, orphan, EntityOperation.ADD); - } - } else { - // Delete not synchronized messages without uid - if (!EntityFolder.DRAFTS.equals(folder.type)) - db.message().deleteOrphans(folder.id); - } + // Delete not synchronized messages without uid + if (!EntityFolder.isOutgoing(folder.type)) + db.message().deleteOrphans(folder.id); int count = MessageHelper.getMessageCount(ifolder); db.folder().setFolderTotal(folder.id, count < 0 ? null : count); diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index f597daa769..3b5e7e7b70 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -546,15 +546,6 @@ public interface DaoMessage { " WHERE folder = :folder") List getUidls(long folder); - @Query("SELECT * FROM message" + - " WHERE folder = :folder" + - " AND uid IS NULL" + - " AND NOT EXISTS" + - " (SELECT * FROM operation" + - " WHERE operation.message = message.id" + - " AND operation.name = '" + EntityOperation.ADD + "')") - List getOrphans(long folder); - @Query("SELECT * FROM message" + " WHERE (:folder IS NULL OR folder = :folder)" + " AND NOT ui_snoozed IS NULL")