do not crash if there are no cache files to delete
java.lang.NullPointerException at org.fdroid.fdroid.Utils.clearOldFiles(Utils.java:347) at org.fdroid.fdroid.CleanCacheService.onHandleIntent(CleanCacheService.java:51) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:194) at android.os.HandlerThread.run(HandlerThread.java:60)
This commit is contained in:
parent
5340fd9350
commit
7f5db2c5b9
@ -343,8 +343,12 @@ public final class Utils {
|
||||
if (dir == null) {
|
||||
return;
|
||||
}
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
long olderThan = System.currentTimeMillis() - (secondsAgo * 1000L);
|
||||
for (File f : dir.listFiles()) {
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
clearOldFiles(f, olderThan);
|
||||
f.delete();
|
||||
|
Loading…
x
Reference in New Issue
Block a user