fix crash when there is no cache when DeleteCacheService runs
java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar) at org.apache.commons.io.FileUtils.isSymlink(FileUtils.java:3107) at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1616) at org.fdroid.fdroid.DeleteCacheService.onHandleWork(DeleteCacheService.java:30) at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:391) at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:382) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237)
This commit is contained in:
parent
593ce5284c
commit
272a0e3f27
@ -27,7 +27,10 @@ public class DeleteCacheService extends JobIntentService {
|
|||||||
Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
|
Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
|
||||||
Log.w(TAG, "Deleting all cached contents!");
|
Log.w(TAG, "Deleting all cached contents!");
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(getCacheDir());
|
File cacheDir = getCacheDir();
|
||||||
|
if (cacheDir != null) {
|
||||||
|
FileUtils.deleteDirectory(cacheDir);
|
||||||
|
}
|
||||||
for (File dir : ContextCompat.getExternalCacheDirs(this)) {
|
for (File dir : ContextCompat.getExternalCacheDirs(this)) {
|
||||||
FileUtils.deleteDirectory(dir);
|
FileUtils.deleteDirectory(dir);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user