From 6fa84776506f137dbfac9eed1d11db203e640c9f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 14 Apr 2016 17:24:22 -0400 Subject: [PATCH] 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. --- app/src/main/java/org/fdroid/fdroid/Utils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/Utils.java b/app/src/main/java/org/fdroid/fdroid/Utils.java index 88a994bd1..c538274e4 100644 --- a/app/src/main/java/org/fdroid/fdroid/Utils.java +++ b/app/src/main/java/org/fdroid/fdroid/Utils.java @@ -325,8 +325,11 @@ public final class Utils { * Using {@link org.fdroid.fdroid.installer.Installer#installPackage(File, String, String)} * is fine since that does the right thing. */ - public static SanitizedFile getApkCacheDir(Context context) { - final SanitizedFile apkCacheDir = new SanitizedFile(StorageUtils.getCacheDirectory(context, true), "apks"); + public static File getApkCacheDir(Context context) { + File apkCacheDir = new File(StorageUtils.getCacheDirectory(context, true), "apks"); + if (apkCacheDir.isFile()) { + apkCacheDir.delete(); + } if (!apkCacheDir.exists()) { apkCacheDir.mkdir(); }