aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-07-08 02:55:35 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-07-08 02:55:35 +0200
commitaf546ae10190ac076cd7b091cd064fb8a5c03519 (patch)
tree2e65babf6d652d8e2700cd5333cb9231c6247504 /OpenKeychain
parentdad2ba0db8d1d5d9d3a0e37990073e39d51f77c9 (diff)
downloadopen-keychain-af546ae10190ac076cd7b091cd064fb8a5c03519.tar.gz
open-keychain-af546ae10190ac076cd7b091cd064fb8a5c03519.tar.bz2
open-keychain-af546ae10190ac076cd7b091cd064fb8a5c03519.zip
apply database fix for bogus rows introduced by issue #1402
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
index 3346926ec..92ad7372a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
@@ -53,7 +53,7 @@ import java.io.IOException;
*/
public class KeychainDatabase extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "openkeychain.db";
- private static final int DATABASE_VERSION = 10;
+ private static final int DATABASE_VERSION = 11;
static Boolean apgHack = false;
private Context mContext;
@@ -274,6 +274,12 @@ public class KeychainDatabase extends SQLiteOpenHelper {
db.execSQL(CREATE_CERTS);
case 10:
// do nothing here, just consolidate
+ case 11:
+ db.execSQL("DELETE FROM api_accounts WHERE key_id BETWEEN 0 AND 3");
+ if (oldVersion == 10) {
+ // no consolidate if we are updating from 10, we're just here for the api_accounts fix
+ return;
+ }
}
@@ -297,10 +303,11 @@ public class KeychainDatabase extends SQLiteOpenHelper {
// It's the Java way =(
String[] dbs = context.databaseList();
for (String db : dbs) {
- if (db.equals("apg.db")) {
+ if ("apg.db".equals(db)) {
hasApgDb = true;
- } else if (db.equals("apg_old.db")) {
+ } else if ("apg_old.db".equals(db)) {
Log.d(Constants.TAG, "Found apg_old.db, delete it!");
+ // noinspection ResultOfMethodCallIgnored - if it doesn't happen, it doesn't happen.
context.getDatabasePath("apg_old.db").delete();
}
}
@@ -384,7 +391,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
}
}
- // delete old database
+ // noinspection ResultOfMethodCallIgnored - not much we can do if this doesn't work
context.getDatabasePath("apg.db").delete();
}
@@ -416,6 +423,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
} else {
in = context.getDatabasePath(DATABASE_NAME);
out = context.getDatabasePath("debug_backup.db");
+ // noinspection ResultOfMethodCallIgnored - this is a pure debug feature, anyways
out.createNewFile();
}
if (!in.canRead()) {