[core] Fix updateWithOnConflict always returns >0 (#1067)

This commit is contained in:
LoveSy 2021-09-06 16:52:29 +08:00 committed by GitHub
parent 26140f7e70
commit 7ab16ade9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -601,7 +601,11 @@ public class ConfigManager {
// insert or update in two step since insert or replace will change the autoincrement mid
int count = (int) db.insertWithOnConflict("modules", null, values, SQLiteDatabase.CONFLICT_IGNORE);
if (count < 0) {
count = db.updateWithOnConflict("modules", values, "module_pkg_name=?", new String[]{packageName}, SQLiteDatabase.CONFLICT_IGNORE);
var cached = cachedModule.getOrDefault(packageName, null);
if (cached == null || cached.apkPath == null || !cached.apkPath.equals(apkPath))
count = db.updateWithOnConflict("modules", values, "module_pkg_name=?", new String[]{packageName}, SQLiteDatabase.CONFLICT_IGNORE);
else
count = 0;
}
if (count > 0) {
// Called by oneway binder