From c3349f0665022677488cb5c0d5c0ce748b3495a6 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 15 Apr 2020 14:09:35 +0200 Subject: [PATCH] I like it extra clean --- app/src/main/java/eu/faircode/email/DaoAttachment.java | 7 +++++-- app/src/main/java/eu/faircode/email/WorkerCleanup.java | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoAttachment.java b/app/src/main/java/eu/faircode/email/DaoAttachment.java index 6334ddb7c8..051f1d6f5a 100644 --- a/app/src/main/java/eu/faircode/email/DaoAttachment.java +++ b/app/src/main/java/eu/faircode/email/DaoAttachment.java @@ -105,8 +105,11 @@ 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)") - int purge(long now); + " 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); @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 03c1937ed6..bba86404ca 100644 --- a/app/src/main/java/eu/faircode/email/WorkerCleanup.java +++ b/app/src/main/java/eu/faircode/email/WorkerCleanup.java @@ -33,6 +33,8 @@ import androidx.work.WorkManager; import androidx.work.Worker; import androidx.work.WorkerParameters; +import net.openid.appauth.BuildConfig; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -92,7 +94,8 @@ public class WorkerCleanup extends Worker { } if (cleanup_attachments) { - int purged = db.attachment().purge(new Date().getTime()); + int purged = db.attachment().purge( + new Date().getTime(), BuildConfig.DEBUG); Log.i("Attachments purged=" + purged); }