Simplify cleanup

This commit is contained in:
M66B 2020-01-08 09:38:59 +01:00
parent 285f60f3d5
commit 966188bbb6
2 changed files with 4 additions and 10 deletions

View File

@ -1200,7 +1200,7 @@ public class FragmentCompose extends FragmentBase {
File dir = new File(getContext().getCacheDir(), "photo");
if (!dir.exists())
dir.mkdir();
File file = new File(dir, new Date().getTime() + ".jpg");
File file = new File(dir, working + ".jpg");
// https://developer.android.com/training/camera/photobasics
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

View File

@ -118,6 +118,7 @@ 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[] photos = new File(context.getCacheDir(), "photo").listFiles();
File[] calendars = new File(context.getCacheDir(), "calendar").listFiles();
if (messages != null)
@ -126,6 +127,8 @@ public class WorkerCleanup extends Worker {
files.addAll(Arrays.asList(revision));
if (references != null)
files.addAll(Arrays.asList(references));
if (photos != null)
files.addAll(Arrays.asList(photos));
if (calendars != null)
files.addAll(Arrays.asList(calendars));
@ -187,15 +190,6 @@ public class WorkerCleanup extends Worker {
}
}
Log.i("Cleanup photos");
File[] photos = new File(context.getCacheDir(), "photo").listFiles();
if (photos != null)
for (File file : photos)
if (manual || file.lastModified() + KEEP_FILES_DURATION < now) {
if (!file.delete())
Log.w("Error deleting " + file);
}
Log.i("Cleanup contacts");
int contacts = db.contact().deleteContacts(now - KEEP_CONTACTS_DURATION);
Log.i("Deleted contacts=" + contacts);