Keep attachment files for a while

pull/160/head
M66B 6 years ago
parent c7597ec2a8
commit a4918e0e94

@ -147,15 +147,16 @@ public class WorkerCleanup extends Worker {
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();
if (attachments != null) if (attachments != null)
for (File file : attachments) { for (File file : attachments)
long id = Long.parseLong(file.getName().split("\\.")[0]); if (manual || file.lastModified() + KEEP_FILES_DURATION < now) {
EntityAttachment attachment = db.attachment().getAttachment(id); long id = Long.parseLong(file.getName().split("\\.")[0]);
if (attachment == null || !attachment.available) { EntityAttachment attachment = db.attachment().getAttachment(id);
Log.i("Deleting " + file); if (attachment == null || !attachment.available) {
if (!file.delete()) Log.i("Deleting " + file);
Log.w("Error deleting " + file); if (!file.delete())
Log.w("Error deleting " + file);
}
} }
}
// Cleanup cached images // Cleanup cached images
Log.i("Cleanup cached image files"); Log.i("Cleanup cached image files");

Loading…
Cancel
Save