From 2ad2b86e88240fc4fdb85fb09fd48d46649c1797 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Fri, 9 Aug 2013 12:18:22 +0100 Subject: [PATCH] Need to be more defensive about cache clearing with slow SD cards --- src/org/fdroid/fdroid/FDroidApp.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/org/fdroid/fdroid/FDroidApp.java b/src/org/fdroid/fdroid/FDroidApp.java index 98c34d1d5..27aac3edd 100644 --- a/src/org/fdroid/fdroid/FDroidApp.java +++ b/src/org/fdroid/fdroid/FDroidApp.java @@ -50,14 +50,15 @@ public class FDroidApp extends Application { if (!prefs.getBoolean("cacheDownloaded", false)) { File local_path = DB.getDataPath(this); - - File[] files = local_path.listFiles(); - // files can be null if the SD card is not ready - we'll just + // Things can be null if the SD card is not ready - we'll just // ignore that and do it next time. - if(files != null) { - for(File f : files) { - if(f.getName().endsWith(".apk")) { - f.delete(); + if(local_path != null) { + File[] files = local_path.listFiles(); + if(files != null) { + for(File f : files) { + if(f.getName().endsWith(".apk")) { + f.delete(); + } } } }