From 1b0af321f7cbb8e19bba75f0d45091e6b53ac907 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 16 Apr 2020 19:37:02 +0200 Subject: [PATCH] Keep attachments of unread/flagged messages --- app/src/main/java/eu/faircode/email/DaoAttachment.java | 9 ++++----- app/src/main/java/eu/faircode/email/WorkerCleanup.java | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoAttachment.java b/app/src/main/java/eu/faircode/email/DaoAttachment.java index 051f1d6f5a..0ccf8c0655 100644 --- a/app/src/main/java/eu/faircode/email/DaoAttachment.java +++ b/app/src/main/java/eu/faircode/email/DaoAttachment.java @@ -105,11 +105,10 @@ public interface DaoAttachment { " JOIN folder ON folder.id = message.folder" + " WHERE a.id = attachment.id" + " AND a.available" + - " AND (message.stored < :now - folder.sync_days * 24 * 3600 * 1000" + - " OR (:extra AND" + - " (folder.type = '" + EntityFolder.TRASH + "'" + - " OR folder.type = '" + EntityFolder.JUNK + "'))))") - int purge(long now, boolean extra); + " AND message.ui_seen" + + " AND NOT message.ui_flagged" + + " AND message.received < :now - (folder.sync_days + 1) * 24 * 3600 * 1000)") + int purge(long now); @Insert long insertAttachment(EntityAttachment attachment); diff --git a/app/src/main/java/eu/faircode/email/WorkerCleanup.java b/app/src/main/java/eu/faircode/email/WorkerCleanup.java index 601b153aa0..0fe452cb74 100644 --- a/app/src/main/java/eu/faircode/email/WorkerCleanup.java +++ b/app/src/main/java/eu/faircode/email/WorkerCleanup.java @@ -107,8 +107,7 @@ public class WorkerCleanup extends Worker { // Delete old attachments if (cleanup_attachments) { - int purged = db.attachment().purge( - new Date().getTime(), BuildConfig.DEBUG); + int purged = db.attachment().purge(new Date().getTime()); Log.i("Attachments purged=" + purged); }