mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-15 15:02:49 +01:00
refactor: tidy up and fix upstream conflicts.
Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
80570a823f
commit
fbf8c46b74
@ -9,7 +9,8 @@ import eu.kanade.tachiyomi.data.backup.models.BackupChapter
|
|||||||
import eu.kanade.tachiyomi.data.backup.models.BackupManga
|
import eu.kanade.tachiyomi.data.backup.models.BackupManga
|
||||||
import eu.kanade.tachiyomi.data.backup.models.BackupSerializer
|
import eu.kanade.tachiyomi.data.backup.models.BackupSerializer
|
||||||
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreJob
|
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreJob
|
||||||
import eu.kanade.tachiyomi.data.backup.restore.MangaRestorer
|
import eu.kanade.tachiyomi.data.backup.restore.RestoreOptions
|
||||||
|
import eu.kanade.tachiyomi.data.backup.restore.restorers.MangaRestorer
|
||||||
import eu.kanade.tachiyomi.data.sync.service.GoogleDriveSyncService
|
import eu.kanade.tachiyomi.data.sync.service.GoogleDriveSyncService
|
||||||
import eu.kanade.tachiyomi.data.sync.service.SyncData
|
import eu.kanade.tachiyomi.data.sync.service.SyncData
|
||||||
import eu.kanade.tachiyomi.data.sync.service.SyncYomiSyncService
|
import eu.kanade.tachiyomi.data.sync.service.SyncYomiSyncService
|
||||||
@ -48,7 +49,7 @@ class SyncManager(
|
|||||||
private val getFavorites: GetFavorites = Injekt.get(),
|
private val getFavorites: GetFavorites = Injekt.get(),
|
||||||
private val getCategories: GetCategories = Injekt.get(),
|
private val getCategories: GetCategories = Injekt.get(),
|
||||||
) {
|
) {
|
||||||
private val backupCreator: BackupCreator = BackupCreator(context)
|
private val backupCreator: BackupCreator = BackupCreator(context, false)
|
||||||
private val notifier: SyncNotifier = SyncNotifier(context)
|
private val notifier: SyncNotifier = SyncNotifier(context)
|
||||||
private val mangaRestorer: MangaRestorer = MangaRestorer()
|
private val mangaRestorer: MangaRestorer = MangaRestorer()
|
||||||
|
|
||||||
@ -72,12 +73,11 @@ class SyncManager(
|
|||||||
suspend fun syncData() {
|
suspend fun syncData() {
|
||||||
val databaseManga = getAllMangaFromDB()
|
val databaseManga = getAllMangaFromDB()
|
||||||
val backup = Backup(
|
val backup = Backup(
|
||||||
backupCreator.backupMangas(databaseManga, BackupCreateFlags.AutomaticDefaults),
|
backupManga = backupCreator.backupMangas(databaseManga, BackupCreateFlags.AutomaticDefaults),
|
||||||
backupCreator.backupCategories(BackupCreateFlags.AutomaticDefaults),
|
backupCategories = backupCreator.backupCategories(BackupCreateFlags.AutomaticDefaults),
|
||||||
emptyList(),
|
backupSources = backupCreator.backupSources(databaseManga),
|
||||||
backupCreator.prepExtensionInfoForSync(databaseManga),
|
backupPreferences = backupCreator.backupAppPreferences(BackupCreateFlags.AutomaticDefaults),
|
||||||
backupCreator.backupAppPreferences(BackupCreateFlags.AutomaticDefaults),
|
backupSourcePreferences = backupCreator.backupSourcePreferences(BackupCreateFlags.AutomaticDefaults),
|
||||||
backupCreator.backupSourcePreferences(BackupCreateFlags.AutomaticDefaults),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create the SyncData object
|
// Create the SyncData object
|
||||||
@ -116,6 +116,8 @@ class SyncManager(
|
|||||||
backupManga = filteredFavorites,
|
backupManga = filteredFavorites,
|
||||||
backupCategories = remoteBackup.backupCategories,
|
backupCategories = remoteBackup.backupCategories,
|
||||||
backupSources = remoteBackup.backupSources,
|
backupSources = remoteBackup.backupSources,
|
||||||
|
backupPreferences = remoteBackup.backupPreferences,
|
||||||
|
backupSourcePreferences = remoteBackup.backupSourcePreferences,
|
||||||
)
|
)
|
||||||
|
|
||||||
// It's local sync no need to restore data. (just update remote data)
|
// It's local sync no need to restore data. (just update remote data)
|
||||||
@ -128,7 +130,11 @@ class SyncManager(
|
|||||||
val backupUri = writeSyncDataToCache(context, newSyncData)
|
val backupUri = writeSyncDataToCache(context, newSyncData)
|
||||||
logcat(LogPriority.DEBUG) { "Got Backup Uri: $backupUri" }
|
logcat(LogPriority.DEBUG) { "Got Backup Uri: $backupUri" }
|
||||||
if (backupUri != null) {
|
if (backupUri != null) {
|
||||||
BackupRestoreJob.start(context, backupUri, sync = true)
|
BackupRestoreJob.start(context, backupUri, sync = true, options = RestoreOptions(
|
||||||
|
appSettings = true,
|
||||||
|
sourceSettings = true,
|
||||||
|
library = true,
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
logcat(LogPriority.ERROR) { "Failed to write sync data to file" }
|
logcat(LogPriority.ERROR) { "Failed to write sync data to file" }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user