Improved raw message file cleanup

pull/160/head
M66B 5 years ago
parent 7a49a7dd89
commit c7597ec2a8

@ -107,7 +107,6 @@ public class WorkerCleanup extends Worker {
File[] messages = new File(context.getFilesDir(), "messages").listFiles();
File[] revision = new File(context.getFilesDir(), "revision").listFiles();
File[] references = new File(context.getFilesDir(), "references").listFiles();
File[] raws = new File(context.getFilesDir(), "raw").listFiles();
if (messages != null)
files.addAll(Arrays.asList(messages));
@ -115,8 +114,6 @@ public class WorkerCleanup extends Worker {
files.addAll(Arrays.asList(revision));
if (references != null)
files.addAll(Arrays.asList(references));
if (raws != null)
files.addAll(Arrays.asList(raws));
// 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
Log.i("Cleanup attachment files");
File[] attachments = new File(context.getFilesDir(), "attachments").listFiles();

Loading…
Cancel
Save