From ef986de6226a6c12f187bd8247c136bbeba0683b Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 13 Sep 2023 12:57:27 +0200 Subject: [PATCH] Revert "Revert "Fixed POP3 cleanup"" This reverts commit 4ec865a658d61fcf72cc4c14a1069a5c63a4d18b. --- app/src/main/java/eu/faircode/email/Core.java | 6 +++--- app/src/main/java/eu/faircode/email/DaoMessage.java | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 265bdf15e4..e27c4408e3 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -161,7 +161,6 @@ class Core { private static final int FIND_RETRY_COUNT = 3; // times private static final long FIND_RETRY_DELAY = 5 * 1000L; // milliseconds private static final int POP3_KEEP_EXTRA = 100; // messages - private static final long POP3_KEEP_DELETED = 3 * 24 * 3600 * 1000L; // milliseconds private static final Map> accountIdentities = new HashMap<>(); @@ -3646,9 +3645,10 @@ class Core { } if (account.max_messages != null && !account.leave_on_device) { - int hidden = db.message().setMessagesUiHide(folder.id, Math.abs(account.max_messages)); + int hidden = db.message().setMessagesUiHide(folder.id, + Math.abs(account.max_messages) + flagged); int deleted = db.message().deleteMessagesKeep(folder.id, - Math.abs(account.max_messages) + flagged + POP3_KEEP_EXTRA, new Date().getTime() - POP3_KEEP_DELETED); + Math.abs(account.max_messages) + flagged + POP3_KEEP_EXTRA); EntityLog.log(context, account.name + " POP" + " cleanup max=" + account.max_messages + " hidden=" + hidden + diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 57f892a1a2..342ca26590 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -1028,8 +1028,7 @@ public interface DaoMessage { " AND id NOT IN (" + " SELECT id FROM message" + " WHERE folder = :folder" + - " AND stored < :before" + " ORDER BY received DESC" + " LIMIT :keep)") - int deleteMessagesKeep(long folder, int keep, long before); + int deleteMessagesKeep(long folder, int keep); } \ No newline at end of file