From 223023f343e3e78c482e654f0228067877fe3603 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 31 Mar 2020 08:44:33 +0200 Subject: [PATCH] Keep downloaded images files 3 days --- app/src/main/java/eu/faircode/email/WorkerCleanup.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/WorkerCleanup.java b/app/src/main/java/eu/faircode/email/WorkerCleanup.java index 0c80e52b00..8ded9492da 100644 --- a/app/src/main/java/eu/faircode/email/WorkerCleanup.java +++ b/app/src/main/java/eu/faircode/email/WorkerCleanup.java @@ -47,6 +47,7 @@ import static android.os.Process.THREAD_PRIORITY_BACKGROUND; public class WorkerCleanup extends Worker { private static final int CLEANUP_INTERVAL = 4; // hours private static final long KEEP_FILES_DURATION = 3600 * 1000L; // milliseconds + private static final long KEEP_IMAGES_DURATION = 3 * 24 * 3600 * 1000L; // milliseconds private static final long KEEP_CONTACTS_DURATION = 180 * 24 * 3600 * 1000L; // milliseconds private static final long KEEP_LOG_DURATION = 24 * 3600 * 1000L; // milliseconds @@ -189,7 +190,8 @@ public class WorkerCleanup extends Worker { if (manual || file.lastModified() + KEEP_FILES_DURATION < now) { long id = Long.parseLong(file.getName().split("_")[0]); EntityMessage message = db.message().getMessage(id); - if (message == null) { + if (manual || message == null || + file.lastModified() + KEEP_IMAGES_DURATION < now) { Log.i("Deleting " + file); if (!file.delete()) Log.w("Error deleting " + file);