Get next update and interval in backup restore
This commit is contained in:
parent
bf81aec3e9
commit
f23c9583eb
1 changed files with 18 additions and 0 deletions
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.data.backup
|
|||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.backup.models.BackupCategory
|
||||
import eu.kanade.tachiyomi.data.backup.models.BackupHistory
|
||||
|
@ -12,10 +13,16 @@ import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
|||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.isActive
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
import tachiyomi.domain.manga.interactor.getCurrentFetchRange
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
import tachiyomi.domain.track.model.Track
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.time.ZonedDateTime
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -23,6 +30,12 @@ class BackupRestorer(
|
|||
private val context: Context,
|
||||
private val notifier: BackupNotifier,
|
||||
) {
|
||||
private val updateManga: UpdateManga = Injekt.get()
|
||||
private val mangaRepository: MangaRepository = Injekt.get()
|
||||
private val chapterRepository: ChapterRepository = Injekt.get()
|
||||
|
||||
private var zonedDateTime = ZonedDateTime.now()
|
||||
private var currentRange = getCurrentFetchRange(zonedDateTime)
|
||||
|
||||
private var backupManager = BackupManager(context)
|
||||
|
||||
|
@ -86,6 +99,8 @@ class BackupRestorer(
|
|||
// Store source mapping for error messages
|
||||
val backupMaps = backup.backupBrokenSources.map { BackupSource(it.name, it.sourceId) } + backup.backupSources
|
||||
sourceMapping = backupMaps.associate { it.sourceId to it.name }
|
||||
zonedDateTime = ZonedDateTime.now()
|
||||
currentRange = getCurrentFetchRange(zonedDateTime)
|
||||
|
||||
return coroutineScope {
|
||||
// Restore individual manga
|
||||
|
@ -128,6 +143,9 @@ class BackupRestorer(
|
|||
// Fetch rest of manga information
|
||||
restoreNewManga(updatedManga, chapters, categories, history, tracks, backupCategories)
|
||||
}
|
||||
val upManga = mangaRepository.getMangaByUrlAndSourceId(manga.url, manga.source)!!
|
||||
val upChapters = chapterRepository.getChapterByMangaId(upManga.id)
|
||||
updateManga.awaitUpdateIntervalMeta(upManga, upChapters, zonedDateTime, currentRange)
|
||||
} catch (e: Exception) {
|
||||
val sourceName = sourceMapping[manga.source] ?: manga.source.toString()
|
||||
errors.add(Date() to "${manga.title} [$sourceName]: ${e.message}")
|
||||
|
|
Reference in a new issue