Fix Full backup, DELETE ALL FULL BACKUPS MADE BEFORE THIS UPDATE
This commit is contained in:
parent
0594efb1c8
commit
6e8ac9cc10
@ -345,14 +345,17 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
|
||||
internal fun restoreCategoriesForManga(manga: Manga, categories: List<Int>, backupCategories: List<BackupCategory>) {
|
||||
val dbCategories = databaseHelper.getCategories().executeAsBlocking()
|
||||
val mangaCategoriesToUpdate = mutableListOf<MangaCategory>()
|
||||
val mappedCategories = categories.mapNotNull { mangaCategory -> backupCategories.firstOrNull { mangaCategory == it.order }?.let { it to mangaCategory } }
|
||||
mappedCategories.forEach { mappedCategory ->
|
||||
categories.forEach { backupCategoryOrder ->
|
||||
backupCategories.firstOrNull {
|
||||
it.order == backupCategoryOrder
|
||||
}?.let { backupCategory ->
|
||||
dbCategories.firstOrNull { dbCategory ->
|
||||
dbCategory.name == mappedCategory.first.name
|
||||
}?.also { dbCategory ->
|
||||
dbCategory.name == backupCategory.name
|
||||
}?.let { dbCategory ->
|
||||
mangaCategoriesToUpdate += MangaCategory.create(manga, dbCategory)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update database
|
||||
if (mangaCategoriesToUpdate.isNotEmpty()) {
|
||||
|
@ -29,9 +29,9 @@ data class BackupManga(
|
||||
@ProtoNumber(13) var dateAdded: Long = 0,
|
||||
@ProtoNumber(14) var viewer: Int = 0,
|
||||
// @ProtoNumber(15) val flags: Int = 0, 1.x value, not used in 0.x
|
||||
@ProtoNumber(15) var chapters: List<BackupChapter> = emptyList(),
|
||||
@ProtoNumber(14) var categories: List<Int> = emptyList(),
|
||||
@ProtoNumber(16) var tracking: List<BackupTracking> = emptyList(),
|
||||
@ProtoNumber(16) var chapters: List<BackupChapter> = emptyList(),
|
||||
@ProtoNumber(17) var categories: List<Int> = emptyList(),
|
||||
@ProtoNumber(18) var tracking: List<BackupTracking> = emptyList(),
|
||||
// Bump by 100 for values that are not saved/implemented in 1.x but are used in 0.x
|
||||
@ProtoNumber(100) var favorite: Boolean = true,
|
||||
@ProtoNumber(101) var chapterFlags: Int = 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user