Better attempt at fixing boot crash when SD card is not ready?

This commit is contained in:
Ciaran Gultnieks 2013-07-15 22:32:09 +01:00
parent 1764ceb55a
commit 63e37a879f
2 changed files with 14 additions and 9 deletions

View File

@ -485,6 +485,8 @@ public class DB {
}
// Get the local storage (cache) path. This will also create it if
// it doesn't exist. It can return null if it's currently unavailable.
public static File getDataPath(Context ctx) {
File f;
if (Utils.hasApi(8)) {
@ -492,12 +494,22 @@ public class DB {
} else {
f = new File(Environment.getExternalStorageDirectory(),
"Android/data/org.fdroid.fdroid/cache");
if(f != null) {
if(!f.exists())
f.mkdirs();
}
}
return f;
}
public static File getIconsPath(Context ctx) {
return new File(getDataPath(ctx), "icons");
File dp = getDataPath(ctx);
if(dp == null)
return null;
File ip = new File(dp, "icons");
if(!ip.exists())
ip.mkdirs();
return ip;
}
private Context mContext;

View File

@ -37,9 +37,7 @@ public class FDroidApp extends Application {
super.onCreate();
File local_path = DB.getDataPath(this);
Log.d("FDroid", "Data path is " + local_path.getPath());
if (!local_path.exists())
local_path.mkdir();
// Clear cached apk files. We used to just remove them after they'd
// been installed, but this causes problems for proprietary gapps
// users since the introduction of verification (on pre-4.2 Android),
@ -59,11 +57,6 @@ public class FDroidApp extends Application {
}
}
File icon_path = DB.getIconsPath(this);
Log.d("FDroid", "Icon path is " + icon_path.getPath());
if (!icon_path.exists())
icon_path.mkdir();
apps = null;
invalidApps = new ArrayList<String>();
Context ctx = getApplicationContext();