Fix default category and manga sometimes not having their category restored (#3891)
This commit is contained in:
@@ -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 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 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 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
|
## [v0.20.4] - 2026-08-05
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import eu.kanade.tachiyomi.data.backup.restore.restorers.PreferenceRestorer
|
|||||||
import eu.kanade.tachiyomi.data.download.DownloadCache
|
import eu.kanade.tachiyomi.data.download.DownloadCache
|
||||||
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
import kotlinx.coroutines.ensureActive
|
import kotlinx.coroutines.ensureActive
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -116,17 +117,27 @@ class BackupRestorer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
if (options.categories) {
|
val restoreCategoriesJob = if (options.categories) {
|
||||||
restoreCategories(backup.backupCategories)
|
restoreCategories(backup.backupCategories)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
}
|
}
|
||||||
if (options.appSettings) {
|
if (options.appSettings) {
|
||||||
restoreAppPreferences(backup.backupPreferences, backup.backupCategories.takeIf { options.categories })
|
restoreAppPreferences(
|
||||||
|
backup.backupPreferences,
|
||||||
|
backup.backupCategories.takeIf { options.categories },
|
||||||
|
restoreCategoriesJob,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (options.sourceSettings) {
|
if (options.sourceSettings) {
|
||||||
restoreSourcePreferences(backup.backupSourcePreferences)
|
restoreSourcePreferences(backup.backupSourcePreferences)
|
||||||
}
|
}
|
||||||
if (options.libraryEntries) {
|
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) {
|
if (options.extensionStores) {
|
||||||
restoreExtensionStores(backup.backupExtensionStores)
|
restoreExtensionStores(backup.backupExtensionStores)
|
||||||
@@ -152,7 +163,9 @@ class BackupRestorer(
|
|||||||
private fun CoroutineScope.restoreManga(
|
private fun CoroutineScope.restoreManga(
|
||||||
backupMangas: List<BackupManga>,
|
backupMangas: List<BackupManga>,
|
||||||
backupCategories: List<BackupCategory>,
|
backupCategories: List<BackupCategory>,
|
||||||
|
categoriesRestoreJob: Job?,
|
||||||
) = launch {
|
) = launch {
|
||||||
|
categoriesRestoreJob?.join()
|
||||||
mangaRestorer.sortByNew(backupMangas)
|
mangaRestorer.sortByNew(backupMangas)
|
||||||
.chunked(100)
|
.chunked(100)
|
||||||
.forEach { chunk ->
|
.forEach { chunk ->
|
||||||
@@ -195,8 +208,10 @@ class BackupRestorer(
|
|||||||
private fun CoroutineScope.restoreAppPreferences(
|
private fun CoroutineScope.restoreAppPreferences(
|
||||||
preferences: List<BackupPreference>,
|
preferences: List<BackupPreference>,
|
||||||
categories: List<BackupCategory>?,
|
categories: List<BackupCategory>?,
|
||||||
|
categoriesRestoreJob: Job?,
|
||||||
) = launch {
|
) = launch {
|
||||||
ensureActive()
|
ensureActive()
|
||||||
|
categoriesRestoreJob?.join()
|
||||||
preferenceRestorer.restoreApp(
|
preferenceRestorer.restoreApp(
|
||||||
preferences,
|
preferences,
|
||||||
categories,
|
categories,
|
||||||
|
|||||||
Reference in New Issue
Block a user