make Utils.getApkCacheDir() more likely to succeed

* if there is a file there, remove it

The paths are all from the system, so are safe. No SanitizedFile is needed.
Plus, this method was not checking if the original and sanitized versions
where different, and instead just creating the sanitized version. I worry
that could cause odd bugs.
This commit is contained in:
Hans-Christoph Steiner 2016-04-14 17:24:22 -04:00
parent 6c47ade379
commit 6fa8477650

View File

@ -325,8 +325,11 @@ public final class Utils {
* Using {@link org.fdroid.fdroid.installer.Installer#installPackage(File, String, String)} * Using {@link org.fdroid.fdroid.installer.Installer#installPackage(File, String, String)}
* is fine since that does the right thing. * is fine since that does the right thing.
*/ */
public static SanitizedFile getApkCacheDir(Context context) { public static File getApkCacheDir(Context context) {
final SanitizedFile apkCacheDir = new SanitizedFile(StorageUtils.getCacheDirectory(context, true), "apks"); File apkCacheDir = new File(StorageUtils.getCacheDirectory(context, true), "apks");
if (apkCacheDir.isFile()) {
apkCacheDir.delete();
}
if (!apkCacheDir.exists()) { if (!apkCacheDir.exists()) {
apkCacheDir.mkdir(); apkCacheDir.mkdir();
} }