From f4bb651fd9dca3aa1ad25e5a86453dcc20c48ee4 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 17 Jan 2022 10:37:35 +0100 Subject: [PATCH] Clear raw message files if disabled --- app/src/main/java/eu/faircode/email/DaoMessage.java | 5 +++++ app/src/main/java/eu/faircode/email/WorkerCleanup.java | 8 +++++++- 2 files changed, 12 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 96dcb96530..639b7b23ae 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -862,6 +862,11 @@ public interface DaoMessage { " AND account IN (SELECT id FROM account WHERE pop = " + EntityAccount.TYPE_IMAP + ")") int clearMessageHeaders(); + @Query("UPDATE message SET raw = NULL" + + " WHERE raw IS NOT NULL" + + " AND account IN (SELECT id FROM account WHERE pop = " + EntityAccount.TYPE_IMAP + ")") + int clearRawMessages(); + @Query("UPDATE message SET fts = 0 WHERE NOT (fts IS 0)") int resetFts(); diff --git a/app/src/main/java/eu/faircode/email/WorkerCleanup.java b/app/src/main/java/eu/faircode/email/WorkerCleanup.java index 060caa94f3..5ede9ab146 100644 --- a/app/src/main/java/eu/faircode/email/WorkerCleanup.java +++ b/app/src/main/java/eu/faircode/email/WorkerCleanup.java @@ -139,6 +139,12 @@ public class WorkerCleanup extends Worker { int headers = db.message().clearMessageHeaders(); Log.i("Cleared message headers=" + headers); } + + // Clear raw message files + if (!download_eml) { + int eml = db.message().clearRawMessages(); + Log.i("Cleared raw messages=" + eml); + } } // Restore alarms @@ -228,7 +234,7 @@ public class WorkerCleanup extends Worker { } } - // Cleanup message files + // Cleanup raw message files if (!download_eml) { Log.i("Cleanup raw message files"); File[] raws = new File(context.getFilesDir(), "raw").listFiles();