diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ba3fc672..28c33736c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co - Fixed app and extension update check running again on configuration change ([@AntsyLich](https://github.com/AntsyLich)) ([#3708](https://github.com/mihonapp/mihon/pull/3708)) - Fixed MangaBaka user start/finish dates drifting in negative offset timezones ([@MajorTanya](https://github.com/MajorTanya)) ([#3711](https://github.com/mihonapp/mihon/pull/3711)) - Fixed MangaBaka scores being wrong when score step size was set to > 1 ([@MajorTanya](https://github.com/MajorTanya)) ([#3740](https://github.com/mihonapp/mihon/pull/3740)) +- Fixed default category and manga sometimes not getting their category set when restoring a backup ([@Secozzi](https://github.com/Secozzi)) ([#3891](https://github.com/mihonapp/mihon/pull/3891)) ## [v0.20.4] - 2026-08-05 ### Fixed diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt index f29fc91ce..a4d0ca231 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt @@ -19,6 +19,7 @@ import eu.kanade.tachiyomi.data.backup.restore.restorers.PreferenceRestorer import eu.kanade.tachiyomi.data.download.DownloadCache import eu.kanade.tachiyomi.util.system.createFileInCacheDir import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.ensureActive import kotlinx.coroutines.launch @@ -116,17 +117,27 @@ class BackupRestorer( } coroutineScope { - if (options.categories) { + val restoreCategoriesJob = if (options.categories) { restoreCategories(backup.backupCategories) + } else { + null } if (options.appSettings) { - restoreAppPreferences(backup.backupPreferences, backup.backupCategories.takeIf { options.categories }) + restoreAppPreferences( + backup.backupPreferences, + backup.backupCategories.takeIf { options.categories }, + restoreCategoriesJob, + ) } if (options.sourceSettings) { restoreSourcePreferences(backup.backupSourcePreferences) } if (options.libraryEntries) { - restoreManga(backup.backupManga, if (options.categories) backup.backupCategories else emptyList()) + restoreManga( + backup.backupManga, + if (options.categories) backup.backupCategories else emptyList(), + restoreCategoriesJob, + ) } if (options.extensionStores) { restoreExtensionStores(backup.backupExtensionStores) @@ -152,7 +163,9 @@ class BackupRestorer( private fun CoroutineScope.restoreManga( backupMangas: List, backupCategories: List, + categoriesRestoreJob: Job?, ) = launch { + categoriesRestoreJob?.join() mangaRestorer.sortByNew(backupMangas) .chunked(100) .forEach { chunk -> @@ -195,8 +208,10 @@ class BackupRestorer( private fun CoroutineScope.restoreAppPreferences( preferences: List, categories: List?, + categoriesRestoreJob: Job?, ) = launch { ensureActive() + categoriesRestoreJob?.join() preferenceRestorer.restoreApp( preferences, categories,