Fix default category and manga sometimes not having their category restored (#3891)

This commit is contained in:
Secozzi
2026-09-06 17:32:38 +02:00
committed by GitHub
parent a82baac3ef
commit 5b69dbad81
2 changed files with 19 additions and 3 deletions
@@ -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<BackupManga>,
backupCategories: List<BackupCategory>,
categoriesRestoreJob: Job?,
) = launch {
categoriesRestoreJob?.join()
mangaRestorer.sortByNew(backupMangas)
.chunked(100)
.forEach { chunk ->
@@ -195,8 +208,10 @@ class BackupRestorer(
private fun CoroutineScope.restoreAppPreferences(
preferences: List<BackupPreference>,
categories: List<BackupCategory>?,
categoriesRestoreJob: Job?,
) = launch {
ensureActive()
categoriesRestoreJob?.join()
preferenceRestorer.restoreApp(
preferences,
categories,