Fix #202: Deleting more apks than sqlite can handle in one query.
The static delete helper function in ApkProvider now supports recursively reducing the size of the list of apks to delete, until it is under the threshold that sqlite can handle.
This commit is contained in:
parent
249af82d7d
commit
898f331bfd
@ -64,7 +64,19 @@ public class ApkProvider extends FDroidProvider {
|
||||
resolver.delete(uri, null, null);
|
||||
}
|
||||
|
||||
public static void deleteApks(Context context, List<Apk> apks) {
|
||||
public static void deleteApks(final Context context, final List<Apk> apks) {
|
||||
if (apks.size() > ApkProvider.MAX_APKS_TO_QUERY) {
|
||||
int middle = apks.size() / 2;
|
||||
List<Apk> apks1 = apks.subList(0, middle);
|
||||
List<Apk> apks2 = apks.subList(middle, apks.size());
|
||||
deleteApks(context, apks1);
|
||||
deleteApks(context, apks2);
|
||||
} else {
|
||||
deleteApksSafely(context, apks);
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteApksSafely(final Context context, final List<Apk> apks) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Uri uri = getContentUri(apks);
|
||||
resolver.delete(uri, null, null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user