mirror of https://github.com/M66B/FairEmail.git
Clear image cache on manual cleanup
This commit is contained in:
parent
5c98af8cdb
commit
7ff26f06bb
|
@ -977,7 +977,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
new SimpleTask<Void>() {
|
new SimpleTask<Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void onExecute(Context context, Bundle args) {
|
protected Void onExecute(Context context, Bundle args) {
|
||||||
JobDaily.cleanup(ActivityView.this);
|
JobDaily.cleanup(ActivityView.this, true);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,19 +64,19 @@ public class JobDaily extends JobService {
|
||||||
executor.submit(new Runnable() {
|
executor.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
cleanup(getApplicationContext());
|
cleanup(getApplicationContext(), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup(Context context) {
|
static void cleanup(Context context, boolean manual) {
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
try {
|
try {
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
|
||||||
Log.i("Start daily job");
|
Log.i("Start daily job manual=" + manual);
|
||||||
|
|
||||||
// Cleanup folders
|
// Cleanup folders
|
||||||
Log.i("Cleanup kept messages");
|
Log.i("Cleanup kept messages");
|
||||||
|
@ -141,7 +141,8 @@ public class JobDaily extends JobService {
|
||||||
File[] images = new File(context.getCacheDir(), "images").listFiles();
|
File[] images = new File(context.getCacheDir(), "images").listFiles();
|
||||||
if (images != null)
|
if (images != null)
|
||||||
for (File file : images)
|
for (File file : images)
|
||||||
if (file.isFile() && (now - file.lastModified()) > CACHE_IMAGE_DURATION) {
|
if (file.isFile())
|
||||||
|
if (manual || now - file.lastModified() > CACHE_IMAGE_DURATION) {
|
||||||
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