mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
Handle backups with categories having default category name (#745)
We do not allow any category to have the default categories name ("default" case-insensitive).
In case the backup includes a category with this name, it won't be matched to any category in our database and also won't insert a new category.
This will then lead to an exception, causing the backup to fail.
This commit is contained in:
@@ -77,7 +77,13 @@ object ProtoBackupImport : ProtoBackupBase() {
|
||||
val categoryMapping =
|
||||
transaction {
|
||||
backup.backupCategories.associate {
|
||||
it.order to CategoryTable.select { CategoryTable.name eq it.name }.first()[CategoryTable.id].value
|
||||
val dbCategory = CategoryTable.select { CategoryTable.name eq it.name }.firstOrNull()
|
||||
val categoryId =
|
||||
dbCategory?.let {
|
||||
categoryResultRow ->
|
||||
categoryResultRow[CategoryTable.id].value
|
||||
} ?: Category.DEFAULT_CATEGORY_ID
|
||||
it.order to categoryId
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user