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)
This commit is contained in:
Daniel Martí 2013-07-26 14:34:40 +02:00
parent f1f1abf095
commit 49dddf42a4
2 changed files with 19 additions and 15 deletions

View File

@ -513,10 +513,7 @@ public class DB {
File dp = getDataPath(ctx); File dp = getDataPath(ctx);
if (dp == null) if (dp == null)
return null; return null;
File ip = new File(dp, "icons"); return new File(dp, "icons");
if(!ip.exists())
ip.mkdirs();
return ip;
} }
private Context mContext; private Context mContext;

View File

@ -186,6 +186,7 @@ public class UpdateService extends IntentService implements ProgressListener {
} }
} }
List<DB.App> acceptedapps = new ArrayList<DB.App>();
if (!changes && success) { if (!changes && success) {
Log.d("FDroid", Log.d("FDroid",
"Not checking app details or compatibility, because all repos were up to date."); "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, sendStatus(STATUS_INFO,
getString(R.string.status_checking_compatibility)); getString(R.string.status_checking_compatibility));
List<DB.App> acceptedapps = new ArrayList<DB.App>(); List<DB.App> prevapps = ((FDroidApp) getApplication()).getApps();
List<DB.App> prevapps = ((FDroidApp) getApplication())
.getApps();
DB db = DB.getDB(); DB db = DB.getDB();
try { try {
@ -252,14 +251,22 @@ public class UpdateService extends IntentService implements ProgressListener {
} finally { } finally {
DB.releaseDB(); 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<DB.App> 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)) { if (success && changes && notify && (newUpdates > prevUpdates)) {