mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-05 03:44:36 -05: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 =
|
val categoryMapping =
|
||||||
transaction {
|
transaction {
|
||||||
backup.backupCategories.associate {
|
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