diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-03-14 20:39:24 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-03-14 20:39:24 +0100 |
commit | ab0d3c397493377eb98f9713fc669fb5ec72a45b (patch) | |
tree | cd7486e1fc92e021f5bc03b797e13127282950e4 /src/main/java/de/pixart/messenger/services | |
parent | c529b0139dd8a5a3f48f4c974daa8d69a1275ed3 (diff) |
fix backup creation for older installations
If you had problems importing the backup you need to create a new backup after this patch
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/ExportBackupService.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/services/ExportBackupService.java b/src/main/java/de/pixart/messenger/services/ExportBackupService.java index 4603a441f..0d976c484 100644 --- a/src/main/java/de/pixart/messenger/services/ExportBackupService.java +++ b/src/main/java/de/pixart/messenger/services/ExportBackupService.java @@ -162,25 +162,32 @@ public class ExportBackupService extends Service { return cursorToString(tablename, cursor, max, false); } - private static String cursorToString(String tablename, Cursor cursor, int max, boolean ignore) { + private static String cursorToString(final String tablename, final Cursor cursor, int max, boolean ignore) { + final boolean identities = SQLiteAxolotlStore.IDENTITIES_TABLENAME.equals(tablename); StringBuilder builder = new StringBuilder(); builder.append("INSERT "); if (ignore) { builder.append("OR IGNORE "); } builder.append("INTO ").append(tablename).append("("); + int skipColumn = -1; for (int i = 0; i < cursor.getColumnCount(); ++i) { + final String name = cursor.getColumnName(i); + if (identities && SQLiteAxolotlStore.TRUSTED.equals(name)) { + skipColumn = i; + continue; + } if (i != 0) { builder.append(','); } - builder.append(cursor.getColumnName(i)); + builder.append(name); } builder.append(") VALUES"); for (int i = 0; i < max; ++i) { if (i != 0) { builder.append(','); } - appendValues(cursor, builder); + appendValues(cursor, builder, skipColumn); if (i < max - 1 && !cursor.moveToNext()) { break; } @@ -190,9 +197,12 @@ public class ExportBackupService extends Service { return builder.toString(); } - private static void appendValues(Cursor cursor, StringBuilder builder) { + private static void appendValues(final Cursor cursor, final StringBuilder builder, final int skipColumn) { builder.append("("); for (int i = 0; i < cursor.getColumnCount(); ++i) { + if (i == skipColumn) { + continue; + } if (i != 0) { builder.append(','); } @@ -206,7 +216,6 @@ public class ExportBackupService extends Service { } } builder.append(")"); - } @Override |