mirror of https://github.com/M66B/FairEmail.git
Improved raw message file cleanup
This commit is contained in:
parent
7a49a7dd89
commit
c7597ec2a8
|
@ -107,7 +107,6 @@ public class WorkerCleanup extends Worker {
|
||||||
File[] messages = new File(context.getFilesDir(), "messages").listFiles();
|
File[] messages = new File(context.getFilesDir(), "messages").listFiles();
|
||||||
File[] revision = new File(context.getFilesDir(), "revision").listFiles();
|
File[] revision = new File(context.getFilesDir(), "revision").listFiles();
|
||||||
File[] references = new File(context.getFilesDir(), "references").listFiles();
|
File[] references = new File(context.getFilesDir(), "references").listFiles();
|
||||||
File[] raws = new File(context.getFilesDir(), "raw").listFiles();
|
|
||||||
|
|
||||||
if (messages != null)
|
if (messages != null)
|
||||||
files.addAll(Arrays.asList(messages));
|
files.addAll(Arrays.asList(messages));
|
||||||
|
@ -115,8 +114,6 @@ public class WorkerCleanup extends Worker {
|
||||||
files.addAll(Arrays.asList(revision));
|
files.addAll(Arrays.asList(revision));
|
||||||
if (references != null)
|
if (references != null)
|
||||||
files.addAll(Arrays.asList(references));
|
files.addAll(Arrays.asList(references));
|
||||||
if (raws != null)
|
|
||||||
files.addAll(Arrays.asList(raws));
|
|
||||||
|
|
||||||
// Cleanup message files
|
// Cleanup message files
|
||||||
Log.i("Cleanup message files");
|
Log.i("Cleanup message files");
|
||||||
|
@ -131,6 +128,21 @@ public class WorkerCleanup extends Worker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup message files
|
||||||
|
Log.i("Cleanup raw message files");
|
||||||
|
File[] raws = new File(context.getFilesDir(), "raw").listFiles();
|
||||||
|
if (raws != null)
|
||||||
|
for (File file : raws)
|
||||||
|
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 || message.raw == null || !message.raw) {
|
||||||
|
Log.i("Deleting " + file);
|
||||||
|
if (!file.delete())
|
||||||
|
Log.w("Error deleting " + file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cleanup attachment files
|
// Cleanup attachment files
|
||||||
Log.i("Cleanup attachment files");
|
Log.i("Cleanup attachment files");
|
||||||
File[] attachments = new File(context.getFilesDir(), "attachments").listFiles();
|
File[] attachments = new File(context.getFilesDir(), "attachments").listFiles();
|
||||||
|
|
Loading…
Reference in New Issue