mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-11 11:38:56 +01:00
Allow creating backups without library entries
- In case you want a backup of just settings? - Also disable backup options if dependent option is disabled (and fix being able to toggle disabled items) - Also fix crash in RestoreBackupScreen due to attempt to parcelize Uri - Make restore validation message a bit nicer
This commit is contained in:
@@ -3,9 +3,7 @@ package eu.kanade.tachiyomi.data.backup
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import eu.kanade.tachiyomi.data.track.TrackerManager
|
||||
import tachiyomi.core.i18n.stringResource
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
import tachiyomi.i18n.MR
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
@@ -19,7 +17,6 @@ class BackupFileValidator(
|
||||
/**
|
||||
* Checks for critical backup file data.
|
||||
*
|
||||
* @throws Exception if manga cannot be found.
|
||||
* @return List of missing sources or missing trackers.
|
||||
*/
|
||||
fun validate(uri: Uri): Results {
|
||||
@@ -29,10 +26,6 @@ class BackupFileValidator(
|
||||
throw IllegalStateException(e)
|
||||
}
|
||||
|
||||
if (backup.backupManga.isEmpty()) {
|
||||
throw IllegalStateException(context.stringResource(MR.strings.invalid_backup_file_missing_manga))
|
||||
}
|
||||
|
||||
val sources = backup.backupSources.associate { it.sourceId to it.name }
|
||||
val missingSources = sources
|
||||
.filter { sourceManager.get(it.key) == null }
|
||||
|
||||
@@ -17,25 +17,34 @@ data class BackupOptions(
|
||||
|
||||
companion object {
|
||||
val libraryOptions = persistentListOf(
|
||||
Entry(
|
||||
label = MR.strings.manga,
|
||||
getter = BackupOptions::libraryEntries,
|
||||
setter = { options, enabled -> options.copy(libraryEntries = enabled) },
|
||||
),
|
||||
Entry(
|
||||
label = MR.strings.categories,
|
||||
getter = BackupOptions::categories,
|
||||
setter = { options, enabled -> options.copy(categories = enabled) },
|
||||
enabled = { it.libraryEntries },
|
||||
),
|
||||
Entry(
|
||||
label = MR.strings.chapters,
|
||||
getter = BackupOptions::chapters,
|
||||
setter = { options, enabled -> options.copy(chapters = enabled) },
|
||||
enabled = { it.libraryEntries },
|
||||
),
|
||||
Entry(
|
||||
label = MR.strings.track,
|
||||
getter = BackupOptions::tracking,
|
||||
setter = { options, enabled -> options.copy(tracking = enabled) },
|
||||
enabled = { it.libraryEntries },
|
||||
),
|
||||
Entry(
|
||||
label = MR.strings.history,
|
||||
getter = BackupOptions::history,
|
||||
setter = { options, enabled -> options.copy(history = enabled) },
|
||||
enabled = { it.libraryEntries },
|
||||
),
|
||||
)
|
||||
|
||||
@@ -54,6 +63,7 @@ data class BackupOptions(
|
||||
label = MR.strings.private_settings,
|
||||
getter = BackupOptions::privateSettings,
|
||||
setter = { options, enabled -> options.copy(privateSettings = enabled) },
|
||||
enabled = { it.appSettings || it.sourceSettings },
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -62,5 +72,6 @@ data class BackupOptions(
|
||||
val label: StringResource,
|
||||
val getter: (BackupOptions) -> Boolean,
|
||||
val setter: (BackupOptions, Boolean) -> BackupOptions,
|
||||
val enabled: (BackupOptions) -> Boolean = { true },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ data class RestoreOptions(
|
||||
val sourceSettings: Boolean = true,
|
||||
) {
|
||||
|
||||
fun anyEnabled() = library || appSettings || sourceSettings
|
||||
|
||||
companion object {
|
||||
val options = persistentListOf(
|
||||
Entry(
|
||||
|
||||
Reference in New Issue
Block a user