From 0136ddfa30efad25bcae3dea806e45ef6029bd6e Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 7 Jan 2019 08:19:48 +0000 Subject: [PATCH] Cleanup orphaned messages --- app/src/main/java/eu/faircode/email/DaoMessage.java | 5 +++++ app/src/main/java/eu/faircode/email/ServiceSynchronize.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 48298b3017..1e49a110f2 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -332,6 +332,11 @@ public interface DaoMessage { " AND NOT uid IS NULL") int deleteLocalMessages(long folder); + @Query("DELETE FROM message" + + " WHERE folder = :folder" + + " AND uid IS NULL") + int deleteOrphans(long folder); + @Query("DELETE FROM message" + " WHERE folder = :folder" + " AND seen") diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 3d6d766d04..8a140ed2f5 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -2234,6 +2234,9 @@ public class ServiceSynchronize extends LifecycleService { } } + // Delete not synchronized messages without uid + db.message().deleteOrphans(folder.id); + db.folder().setFolderSyncState(folder.id, "downloading"); //fp.add(IMAPFolder.FetchProfileItem.MESSAGE);