From 49dddf42a4234763ba8a06c82c5ed9d932c36b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 26 Jul 2013 14:34:40 +0200 Subject: [PATCH] Download all icons if cache/icons/ is missing This way, after wiping cache one can redownload all the icons by just updating the repos (even if they don't need updates, this will work) --- src/org/fdroid/fdroid/DB.java | 7 ++---- src/org/fdroid/fdroid/UpdateService.java | 27 +++++++++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 3ad97dfe6..6daeddbe7 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -511,12 +511,9 @@ public class DB { public static File getIconsPath(Context ctx) { File dp = getDataPath(ctx); - if(dp == null) + if (dp == null) return null; - File ip = new File(dp, "icons"); - if(!ip.exists()) - ip.mkdirs(); - return ip; + return new File(dp, "icons"); } private Context mContext; diff --git a/src/org/fdroid/fdroid/UpdateService.java b/src/org/fdroid/fdroid/UpdateService.java index 106d3b92a..68881d5a4 100644 --- a/src/org/fdroid/fdroid/UpdateService.java +++ b/src/org/fdroid/fdroid/UpdateService.java @@ -186,6 +186,7 @@ public class UpdateService extends IntentService implements ProgressListener { } } + List acceptedapps = new ArrayList(); if (!changes && success) { Log.d("FDroid", "Not checking app details or compatibility, because all repos were up to date."); @@ -193,9 +194,7 @@ public class UpdateService extends IntentService implements ProgressListener { sendStatus(STATUS_INFO, getString(R.string.status_checking_compatibility)); - List acceptedapps = new ArrayList(); - List prevapps = ((FDroidApp) getApplication()) - .getApps(); + List prevapps = ((FDroidApp) getApplication()).getApps(); DB db = DB.getDB(); try { @@ -252,16 +251,24 @@ public class UpdateService extends IntentService implements ProgressListener { } finally { DB.releaseDB(); } - if (success) { - sendStatus(STATUS_INFO, - getString(R.string.status_downloading_icons)); - for (DB.App app : acceptedapps) - getIcon(app, repos); - ((FDroidApp) getApplication()).invalidateAllApps(); - } } + if (success) { + File d = DB.getIconsPath(this); + List toDownloadIcons = acceptedapps; + if (!d.exists()) { + Log.d("FDroid", "Icons were wiped. Re-downloading all of them."); + d.mkdirs(); + toDownloadIcons = ((FDroidApp) getApplication()).getApps(); + } + sendStatus(STATUS_INFO, + getString(R.string.status_downloading_icons)); + for (DB.App app : toDownloadIcons) + getIcon(app, repos); + ((FDroidApp) getApplication()).invalidateAllApps(); + } + if (success && changes && notify && (newUpdates > prevUpdates)) { Log.d("FDroid", "Notifying updates. Apps before:" + prevUpdates + ", apps after: " + newUpdates);