Skip to content

Commit

Permalink
fix could not import a partially corrupted backup
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-chung committed Feb 16, 2024
1 parent cc2f476 commit e8cb50a
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ class DataDumpImporter {
}
}

fun copyWithNewId(current: TreeObject): TreeObject {
fun copyWithNewId(current: TreeObject): TreeObject? {
return when (current) {
is TreeFolder -> current.copy(
id = uuidString(),
childs = current.childs.map { copyWithNewId(it) }.toMutableList(),
childs = current.childs.mapNotNull { copyWithNewId(it) }.toMutableList(),
)
is TreeRequest -> current.copy(
id = newRequestTemplateIds[current.id]!!
id = newRequestTemplateIds[current.id] ?: return null
)
}
}
Expand All @@ -129,7 +129,7 @@ class DataDumpImporter {
environments = it.environments.map {
it.copy(id = uuidString())
}.toMutableList(),
treeObjects = it.treeObjects.map { copyWithNewId(it) }.toMutableList(),
treeObjects = it.treeObjects.mapNotNull { copyWithNewId(it) }.toMutableList(),
grpcApiSpecIds = it.grpcApiSpecIds.mapNotNull { newApiSpecIds[it] }.toMutableSet(),
)
}.toMutableList()
Expand Down

0 comments on commit e8cb50a

Please sign in to comment.