From 8d245fc75480905c380bc05d69ff3d3e2d31d8bd Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 8 Dec 2019 11:33:09 +0100 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20use=20secure=20delete=20when=20?= =?UTF-8?q?migrating=20edit=20column?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conversations/persistance/DatabaseBackend.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 823ac8d28..02ac484da 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -195,7 +195,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { @Override public void onConfigure(SQLiteDatabase db) { db.execSQL("PRAGMA foreign_keys=ON"); - db.rawQuery("PRAGMA secure_delete=ON", null); + db.rawQuery("PRAGMA secure_delete=ON", null).close(); } @Override @@ -548,7 +548,12 @@ public class DatabaseBackend extends SQLiteOpenHelper { } if (oldVersion < 46 && newVersion >= 46) { + final long start = SystemClock.elapsedRealtime(); + db.rawQuery("PRAGMA secure_delete = FALSE", null).close(); db.execSQL("update "+Message.TABLENAME+" set "+Message.EDITED+"=NULL"); + db.rawQuery("PRAGMA secure_delete=ON", null).close(); + final long diff = SystemClock.elapsedRealtime() - start; + Log.d(Config.LOGTAG,"deleted old edit information in "+diff+"ms"); } } @@ -584,14 +589,14 @@ public class DatabaseBackend extends SQLiteOpenHelper { String newJid; try { newJid = Jid.of(cursor.getString(cursor.getColumnIndex(Contact.JID))).toString(); - } catch (IllegalArgumentException ignored) { + } catch (final IllegalArgumentException e) { Log.e(Config.LOGTAG, "Failed to migrate Contact JID " + cursor.getString(cursor.getColumnIndex(Contact.JID)) - + ": " + ignored + ". Skipping..."); + + ": Skipping...", e); continue; } - String updateArgs[] = { + final String[] updateArgs = { newJid, cursor.getString(cursor.getColumnIndex(Contact.ACCOUNT)), cursor.getString(cursor.getColumnIndex(Contact.JID)),