Improved logging around backup export.

This commit is contained in:
Greyson Parrelli
2023-03-24 10:17:23 -04:00
parent 351baa4135
commit 5914a4d1cf

View File

@@ -282,6 +282,8 @@ public class FullBackupExporter extends FullBackupBase {
{
List<String> tablesInOrder = getTablesToExportInOrder(input);
Log.i(TAG, "Exporting tables in the following order: " + tablesInOrder);
Map<String, String> 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<String, Set<String>> dependsOn = new LinkedHashMap<>();
for (String table : tables) {
dependsOn.put(table, SqlUtil.getForeignKeyDependencies(input, table));
}
for (String table : tables) {
Set<String> 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)) {