From e2b89a8703846b73ececcc20d51658060d5ffc5d Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 26 Jan 2019 18:11:51 +0000 Subject: [PATCH] Prevent deleting local messages with pending add operation --- app/src/main/java/eu/faircode/email/DaoMessage.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 6e08d9d8d8..d039ef2dc3 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -371,7 +371,11 @@ public interface DaoMessage { @Query("DELETE FROM message" + " WHERE folder = :folder" + " AND uid IS NULL" + - " AND NOT ui_browsed") + " AND NOT ui_browsed" + + " AND NOT EXISTS" + + " (SELECT * FROM operation" + + " WHERE operation.message = message.id" + + " AND operation.name = '" + EntityOperation.ADD + "')") int deleteOrphans(long folder); @Query("DELETE FROM message" +