Follow weekday and monthly release patterns for next update and back it up

This commit is contained in:
AntsyLich
2026-10-10 01:24:05 +06:00
parent 44c1e1915d
commit 292381662a
6 changed files with 296 additions and 68 deletions
@@ -99,4 +99,5 @@ private fun Manga.toBackupManga() =
notes = this.notes,
initialized = this.initialized,
memo = this.memo.toByteArray(),
nextUpdate = this.nextUpdate.toEpochMillisOrZero(),
)
@@ -48,6 +48,7 @@ class BackupManga(
@ProtoNumber(110) var notes: String = "",
@ProtoNumber(111) var initialized: Boolean = false,
@ProtoNumber(112) var memo: ByteArray = JsonObjectEmptyBytes,
@ProtoNumber(113) var nextUpdate: Long = 0,
) {
fun getMangaImpl(): Manga {
return Manga.create().copy(
@@ -75,6 +76,7 @@ class BackupManga(
notes = this@BackupManga.notes,
initialized = this@BackupManga.initialized,
memo = this@BackupManga.memo.toJsonObject(),
nextUpdate = this@BackupManga.nextUpdate.toInstantOrNull(),
)
}
}
@@ -58,8 +58,13 @@ class MangaRestorer(
)
}
restoreRepository.restoreManga(entries) {
fetchInterval.withFetchInterval(it, now, timeZone, currentFetchWindow)
restoreRepository.restoreManga(entries) { manga ->
fetchInterval.withFetchInterval(manga, now, timeZone, currentFetchWindow).apply {
// A next update still ahead was worked out with the chapters the backup came from
manga.nextUpdate
?.takeIf { it >= currentFetchWindow.start }
?.let { nextUpdate = it }
}
}
}
}