mirror of https://github.com/M66B/FairEmail.git
Keep downloaded images files 3 days
This commit is contained in:
parent
b726d35131
commit
223023f343
|
@ -47,6 +47,7 @@ import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
||||||
public class WorkerCleanup extends Worker {
|
public class WorkerCleanup extends Worker {
|
||||||
private static final int CLEANUP_INTERVAL = 4; // hours
|
private static final int CLEANUP_INTERVAL = 4; // hours
|
||||||
private static final long KEEP_FILES_DURATION = 3600 * 1000L; // milliseconds
|
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_CONTACTS_DURATION = 180 * 24 * 3600 * 1000L; // milliseconds
|
||||||
private static final long KEEP_LOG_DURATION = 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) {
|
if (manual || file.lastModified() + KEEP_FILES_DURATION < now) {
|
||||||
long id = Long.parseLong(file.getName().split("_")[0]);
|
long id = Long.parseLong(file.getName().split("_")[0]);
|
||||||
EntityMessage message = db.message().getMessage(id);
|
EntityMessage message = db.message().getMessage(id);
|
||||||
if (message == null) {
|
if (manual || message == null ||
|
||||||
|
file.lastModified() + KEEP_IMAGES_DURATION < now) {
|
||||||
Log.i("Deleting " + file);
|
Log.i("Deleting " + file);
|
||||||
if (!file.delete())
|
if (!file.delete())
|
||||||
Log.w("Error deleting " + file);
|
Log.w("Error deleting " + file);
|
||||||
|
|
Loading…
Reference in New Issue