diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.java b/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.java index 146c659f2b..a1e0eb24ec 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.java @@ -282,6 +282,8 @@ public class FullBackupExporter extends FullBackupBase { { List tablesInOrder = getTablesToExportInOrder(input); + Log.i(TAG, "Exporting tables in the following order: " + tablesInOrder); + Map createStatementsByTable = new HashMap<>(); try (Cursor cursor = input.rawQuery("SELECT sql, name, type FROM sqlite_master WHERE type = 'table' AND sql NOT NULL", null)) { @@ -328,12 +330,16 @@ public class FullBackupExporter extends FullBackupBase { .sorted() .collect(Collectors.toList()); - Map> dependsOn = new LinkedHashMap<>(); for (String table : tables) { dependsOn.put(table, SqlUtil.getForeignKeyDependencies(input, table)); } - + + for (String table : tables) { + Set dependsOnTable = dependsOn.keySet().stream().filter(t -> dependsOn.get(t).contains(table)).collect(Collectors.toSet()); + Log.i(TAG, "Tables that depend on " + table + ": " + dependsOnTable); + } + return computeTableOrder(dependsOn); } @@ -396,6 +402,8 @@ public class FullBackupExporter extends FullBackupBase { @NonNull BackupCancellationSignal cancellationSignal) throws IOException { + Log.d(TAG, "Exporting table: " + table); + String template = "INSERT INTO " + table + " VALUES "; try (Cursor cursor = input.rawQuery("SELECT * FROM " + table, null)) {