Loading k9mail/src/main/java/com/fsck/k9/mailstore/migrations/MigrationTo56.java +31 −13 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ public class MigrationTo56 { public static void migratePendingCommands(SQLiteDatabase db) { List<PendingCommand> pendingCommmands = new ArrayList<>(); if (columnExists(db, "pending_commands", "arguments")) { for (OldPendingCommand oldPendingCommand : getPendingCommands(db)) { PendingCommand newPendingCommand = migratePendingCommand(oldPendingCommand); pendingCommmands.add(newPendingCommand); Loading @@ -52,6 +54,22 @@ public class MigrationTo56 { db.insert("pending_commands", "command", cv); } } } private static boolean columnExists(SQLiteDatabase db, String table, String columnName) { Cursor columnCursor = db.rawQuery("PRAGMA table_info("+table+")", null); columnCursor.moveToFirst(); boolean foundColumn = false; while (!columnCursor.isAfterLast()) { if(columnCursor.getString(1).equals(columnName)) { foundColumn = true; break; } columnCursor.moveToNext(); } columnCursor.close(); return foundColumn; } @VisibleForTesting static PendingCommand migratePendingCommand(OldPendingCommand oldPendingCommand) { Loading Loading
k9mail/src/main/java/com/fsck/k9/mailstore/migrations/MigrationTo56.java +31 −13 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ public class MigrationTo56 { public static void migratePendingCommands(SQLiteDatabase db) { List<PendingCommand> pendingCommmands = new ArrayList<>(); if (columnExists(db, "pending_commands", "arguments")) { for (OldPendingCommand oldPendingCommand : getPendingCommands(db)) { PendingCommand newPendingCommand = migratePendingCommand(oldPendingCommand); pendingCommmands.add(newPendingCommand); Loading @@ -52,6 +54,22 @@ public class MigrationTo56 { db.insert("pending_commands", "command", cv); } } } private static boolean columnExists(SQLiteDatabase db, String table, String columnName) { Cursor columnCursor = db.rawQuery("PRAGMA table_info("+table+")", null); columnCursor.moveToFirst(); boolean foundColumn = false; while (!columnCursor.isAfterLast()) { if(columnCursor.getString(1).equals(columnName)) { foundColumn = true; break; } columnCursor.moveToNext(); } columnCursor.close(); return foundColumn; } @VisibleForTesting static PendingCommand migratePendingCommand(OldPendingCommand oldPendingCommand) { Loading