Correctly purge removed apks.
There were two bugs in this code that have been fixed. Both were introduced while moving to a lower memory consumption version of the repo updater. The first is that for each app which is updated by a particular repo, it was not correctly asking the question: "Which apks belonging to this apk, and provided by this repo, are no longer provided by this repo?". It was accidentally only comparing the version number of existing apks in the DB and new apks from the index. This ensures that the apks being checked to see if they need to be removed or not are those with the same package name AND the same version code (provided by the same repo). The second bug is that when it was persisting a set of apps + apks to the database, it would ask for existing apks already in the database for these apps. In this case, there was a bug where of the 50 apps being persisted, it would only retrieve the first of these 50 apps from the database to decide if it needed to be cleaned up or not. Now, it correctly retrieves data from the DB belonging to all 50 apps.
This commit is contained in:
parent
4bbd0d83ef
commit
70bf49c3ac
@ -340,7 +340,7 @@ public class ApkProvider extends FDroidProvider {
|
||||
if (i != 0) {
|
||||
builder.append(',');
|
||||
}
|
||||
builder.append(apks.get(0).id);
|
||||
builder.append(apks.get(i).id);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
@ -243,27 +243,20 @@ public class RepoPersister {
|
||||
*/
|
||||
@Nullable
|
||||
private ContentProviderOperation deleteOrphanedApks(List<App> apps, Map<String, List<Apk>> packages) {
|
||||
|
||||
String[] projection = new String[]{ApkProvider.DataColumns.APK_ID, ApkProvider.DataColumns.VERSION_CODE};
|
||||
List<Apk> existing = ApkProvider.Helper.find(context, repo, apps, projection);
|
||||
|
||||
List<Apk> toDelete = new ArrayList<>();
|
||||
|
||||
for (Apk existingApk : existing) {
|
||||
|
||||
boolean shouldStay = false;
|
||||
|
||||
for (Map.Entry<String, List<Apk>> entry : packages.entrySet()) {
|
||||
for (Apk newApk : entry.getValue()) {
|
||||
if (packages.containsKey(existingApk.id)) {
|
||||
for (Apk newApk : packages.get(existingApk.id)) {
|
||||
if (newApk.vercode == existingApk.vercode) {
|
||||
shouldStay = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldStay) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldStay) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user