From ba533f30ce70bdcfbfaaae3e7758dbe38fe6fb1b Mon Sep 17 00:00:00 2001 From: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> Date: Sun, 25 Sep 2022 11:12:36 -0300 Subject: [PATCH] Add support to update strategy on global update (#7902) * Add support to update strategy. * Add JavaDoc and bump the LIB_VERSION_MAX constant. * Fix a word typo. * Store update strategy enum as integer in the DB. --- .../java/eu/kanade/data/DatabaseAdapter.kt | 10 +++++++++ .../java/eu/kanade/data/manga/MangaMapper.kt | 16 +++++++++----- .../kanade/data/manga/MangaRepositoryImpl.kt | 3 +++ .../domain/manga/interactor/UpdateManga.kt | 1 + .../eu/kanade/domain/manga/model/Manga.kt | 5 +++++ .../kanade/domain/manga/model/MangaUpdate.kt | 3 +++ .../java/eu/kanade/tachiyomi/AppModule.kt | 2 ++ .../tachiyomi/data/backup/BackupManager.kt | 3 +++ .../data/backup/models/BackupManga.kt | 4 ++++ .../tachiyomi/data/database/models/Manga.kt | 1 + .../data/database/models/MangaImpl.kt | 4 ++++ .../data/library/LibraryUpdateService.kt | 4 ++++ .../extension/util/ExtensionLoader.kt | 2 +- app/src/main/sqldelight/data/mangas.sq | 11 ++++++---- app/src/main/sqldelight/migrations/20.sqm | 1 + i18n/src/main/res/values/strings.xml | 1 + .../kanade/tachiyomi/source/model/SManga.kt | 5 +++++ .../tachiyomi/source/model/SMangaImpl.kt | 2 ++ .../tachiyomi/source/model/UpdateStrategy.kt | 22 +++++++++++++++++++ 19 files changed, 89 insertions(+), 11 deletions(-) create mode 100644 app/src/main/sqldelight/migrations/20.sqm create mode 100644 source-api/src/main/java/eu/kanade/tachiyomi/source/model/UpdateStrategy.kt diff --git a/app/src/main/java/eu/kanade/data/DatabaseAdapter.kt b/app/src/main/java/eu/kanade/data/DatabaseAdapter.kt index d51e2c514b..48c8974961 100644 --- a/app/src/main/java/eu/kanade/data/DatabaseAdapter.kt +++ b/app/src/main/java/eu/kanade/data/DatabaseAdapter.kt @@ -1,6 +1,7 @@ package eu.kanade.data import com.squareup.sqldelight.ColumnAdapter +import eu.kanade.tachiyomi.source.model.UpdateStrategy import java.util.Date val dateAdapter = object : ColumnAdapter { @@ -18,3 +19,12 @@ val listOfStringsAdapter = object : ColumnAdapter, String> { } override fun encode(value: List) = value.joinToString(separator = listOfStringsSeparator) } + +val updateStrategyAdapter = object : ColumnAdapter { + private val enumValues by lazy { UpdateStrategy.values() } + + override fun decode(databaseValue: Long): UpdateStrategy = + enumValues.getOrElse(databaseValue.toInt()) { UpdateStrategy.ALWAYS_UPDATE } + + override fun encode(value: UpdateStrategy): Long = value.ordinal.toLong() +} diff --git a/app/src/main/java/eu/kanade/data/manga/MangaMapper.kt b/app/src/main/java/eu/kanade/data/manga/MangaMapper.kt index 4d2ad1f95c..f584f2bb77 100644 --- a/app/src/main/java/eu/kanade/data/manga/MangaMapper.kt +++ b/app/src/main/java/eu/kanade/data/manga/MangaMapper.kt @@ -3,9 +3,10 @@ package eu.kanade.data.manga import eu.kanade.domain.chapter.model.Chapter import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.data.database.models.LibraryManga +import eu.kanade.tachiyomi.source.model.UpdateStrategy -val mangaMapper: (Long, Long, String, String?, String?, String?, List?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long) -> Manga = - { id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, _, initialized, viewer, chapterFlags, coverLastModified, dateAdded -> +val mangaMapper: (Long, Long, String, String?, String?, String?, List?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, UpdateStrategy) -> Manga = + { id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, _, initialized, viewer, chapterFlags, coverLastModified, dateAdded, updateStrategy -> Manga( id = id, source = source, @@ -23,12 +24,13 @@ val mangaMapper: (Long, Long, String, String?, String?, String?, List?, genre = genre, status = status, thumbnailUrl = thumbnailUrl, + updateStrategy = updateStrategy, initialized = initialized, ) } -val mangaChapterMapper: (Long, Long, String, String?, String?, String?, List?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, Long, Long, String, String, String?, Boolean, Boolean, Long, Float, Long, Long, Long) -> Pair = - { _id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, next_update, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, chapterId, mangaId, chapterUrl, name, scanlator, read, bookmark, lastPageRead, chapterNumber, sourceOrder, dateFetch, dateUpload -> +val mangaChapterMapper: (Long, Long, String, String?, String?, String?, List?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, UpdateStrategy, Long, Long, String, String, String?, Boolean, Boolean, Long, Float, Long, Long, Long) -> Pair = + { _id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, next_update, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, updateStrategy, chapterId, mangaId, chapterUrl, name, scanlator, read, bookmark, lastPageRead, chapterNumber, sourceOrder, dateFetch, dateUpload -> Manga( id = _id, source = source, @@ -46,6 +48,7 @@ val mangaChapterMapper: (Long, Long, String, String?, String?, String?, List?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, Long, Long, Long) -> LibraryManga = - { _id, source, url, artist, author, description, genre, title, status, thumbnail_url, favorite, last_update, next_update, initialized, viewer, chapter_flags, cover_last_modified, date_added, unread_count, read_count, category -> +val libraryManga: (Long, Long, String, String?, String?, String?, List?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, UpdateStrategy, Long, Long, Long) -> LibraryManga = + { _id, source, url, artist, author, description, genre, title, status, thumbnail_url, favorite, last_update, next_update, initialized, viewer, chapter_flags, cover_last_modified, date_added, update_strategy, unread_count, read_count, category -> LibraryManga().apply { this.id = _id this.source = source @@ -78,6 +81,7 @@ val libraryManga: (Long, Long, String, String?, String?, String?, List?, this.thumbnail_url = thumbnail_url this.favorite = favorite this.last_update = last_update ?: 0 + this.update_strategy = update_strategy this.initialized = initialized this.viewer_flags = viewer.toInt() this.chapter_flags = chapter_flags.toInt() diff --git a/app/src/main/java/eu/kanade/data/manga/MangaRepositoryImpl.kt b/app/src/main/java/eu/kanade/data/manga/MangaRepositoryImpl.kt index 1731fb2250..84b7b7cb03 100644 --- a/app/src/main/java/eu/kanade/data/manga/MangaRepositoryImpl.kt +++ b/app/src/main/java/eu/kanade/data/manga/MangaRepositoryImpl.kt @@ -2,6 +2,7 @@ package eu.kanade.data.manga import eu.kanade.data.DatabaseHandler import eu.kanade.data.listOfStringsAdapter +import eu.kanade.data.updateStrategyAdapter import eu.kanade.domain.manga.model.Manga import eu.kanade.domain.manga.model.MangaUpdate import eu.kanade.domain.manga.repository.MangaRepository @@ -92,6 +93,7 @@ class MangaRepositoryImpl( chapterFlags = manga.chapterFlags, coverLastModified = manga.coverLastModified, dateAdded = manga.dateAdded, + updateStrategy = manga.updateStrategy, ) mangasQueries.selectLastInsertedRowId() } @@ -138,6 +140,7 @@ class MangaRepositoryImpl( coverLastModified = value.coverLastModified, dateAdded = value.dateAdded, mangaId = value.id, + updateStrategy = value.updateStrategy?.let(updateStrategyAdapter::encode), ) } } diff --git a/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt b/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt index 8e0516a638..c3f06fac82 100644 --- a/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt @@ -68,6 +68,7 @@ class UpdateManga( genre = remoteManga.getGenres(), thumbnailUrl = thumbnailUrl, status = remoteManga.status.toLong(), + updateStrategy = remoteManga.update_strategy, initialized = true, ), ) diff --git a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt index 10044044fd..93eddd7bf4 100644 --- a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt @@ -6,6 +6,7 @@ import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.widget.ExtendedNavigationView import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -29,6 +30,7 @@ data class Manga( val genre: List?, val status: Long, val thumbnailUrl: String?, + val updateStrategy: UpdateStrategy, val initialized: Boolean, ) : Serializable { @@ -143,6 +145,7 @@ data class Manga( genre = null, status = 0L, thumbnailUrl = null, + updateStrategy = UpdateStrategy.ALWAYS_UPDATE, initialized = false, ) } @@ -180,6 +183,7 @@ fun Manga.toDbManga(): DbManga = MangaImpl().also { it.genre = genre?.let(listOfStringsAdapter::encode) it.status = status.toInt() it.thumbnail_url = thumbnailUrl + it.update_strategy = updateStrategy it.initialized = initialized } @@ -201,6 +205,7 @@ fun Manga.toMangaUpdate(): MangaUpdate { genre = genre, status = status, thumbnailUrl = thumbnailUrl, + updateStrategy = updateStrategy, initialized = initialized, ) } diff --git a/app/src/main/java/eu/kanade/domain/manga/model/MangaUpdate.kt b/app/src/main/java/eu/kanade/domain/manga/model/MangaUpdate.kt index 0d18659d46..03035fe070 100644 --- a/app/src/main/java/eu/kanade/domain/manga/model/MangaUpdate.kt +++ b/app/src/main/java/eu/kanade/domain/manga/model/MangaUpdate.kt @@ -1,5 +1,7 @@ package eu.kanade.domain.manga.model +import eu.kanade.tachiyomi.source.model.UpdateStrategy + data class MangaUpdate( val id: Long, val source: Long? = null, @@ -17,5 +19,6 @@ data class MangaUpdate( val genre: List? = null, val status: Long? = null, val thumbnailUrl: String? = null, + val updateStrategy: UpdateStrategy? = null, val initialized: Boolean? = null, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt index f12b85783f..3471b92c07 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt @@ -13,6 +13,7 @@ import eu.kanade.data.AndroidDatabaseHandler import eu.kanade.data.DatabaseHandler import eu.kanade.data.dateAdapter import eu.kanade.data.listOfStringsAdapter +import eu.kanade.data.updateStrategyAdapter import eu.kanade.domain.backup.service.BackupPreferences import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.download.service.DownloadPreferences @@ -87,6 +88,7 @@ class AppModule(val app: Application) : InjektModule { ), mangasAdapter = Mangas.Adapter( genreAdapter = listOfStringsAdapter, + update_strategyAdapter = updateStrategyAdapter, ), ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt index c1ff21f079..380ca2e17e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt @@ -7,6 +7,7 @@ import com.hippo.unifile.UniFile import data.Manga_sync import data.Mangas import eu.kanade.data.DatabaseHandler +import eu.kanade.data.updateStrategyAdapter import eu.kanade.domain.backup.service.BackupPreferences import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.model.Category @@ -506,6 +507,7 @@ class BackupManager( chapterFlags = manga.chapter_flags.toLong(), coverLastModified = manga.cover_last_modified, dateAdded = manga.date_added, + updateStrategy = manga.update_strategy, ) mangasQueries.selectLastInsertedRowId() } @@ -531,6 +533,7 @@ class BackupManager( coverLastModified = manga.cover_last_modified, dateAdded = manga.date_added, mangaId = manga.id!!, + updateStrategy = manga.update_strategy.let(updateStrategyAdapter::encode), ) } return manga.id!! diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt index 0edfd6d7f0..3f6f1d8dfe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt @@ -4,6 +4,7 @@ import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.data.database.models.ChapterImpl import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.database.models.TrackImpl +import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber @@ -38,6 +39,7 @@ data class BackupManga( @ProtoNumber(102) var brokenHistory: List = emptyList(), @ProtoNumber(103) var viewer_flags: Int? = null, @ProtoNumber(104) var history: List = emptyList(), + @ProtoNumber(105) var updateStrategy: UpdateStrategy = UpdateStrategy.ALWAYS_UPDATE, ) { fun getMangaImpl(): MangaImpl { return MangaImpl().apply { @@ -54,6 +56,7 @@ data class BackupManga( date_added = this@BackupManga.dateAdded viewer_flags = this@BackupManga.viewer_flags ?: this@BackupManga.viewer chapter_flags = this@BackupManga.chapterFlags + update_strategy = this@BackupManga.updateStrategy } } @@ -86,6 +89,7 @@ data class BackupManga( viewer = (manga.viewerFlags.toInt() and ReadingModeType.MASK), viewer_flags = manga.viewerFlags.toInt(), chapterFlags = manga.chapterFlags.toInt(), + updateStrategy = manga.updateStrategy, ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt index 4d19bfe91c..c4894636eb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt @@ -93,6 +93,7 @@ fun Manga.toDomainManga(): DomainManga? { genre = getGenres(), status = status.toLong(), thumbnailUrl = thumbnail_url, + updateStrategy = update_strategy, initialized = initialized, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt index 7e27238407..7cc286bba0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt @@ -1,5 +1,7 @@ package eu.kanade.tachiyomi.data.database.models +import eu.kanade.tachiyomi.source.model.UpdateStrategy + open class MangaImpl : Manga { override var id: Long? = null @@ -28,6 +30,8 @@ open class MangaImpl : Manga { override var date_added: Long = 0 + override var update_strategy: UpdateStrategy = UpdateStrategy.ALWAYS_UPDATE + override var initialized: Boolean = false override var viewer_flags: Int = 0 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 8c3cc051a4..c17d308bc8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -43,6 +43,7 @@ import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.UnmeteredSource import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.util.lang.withIOContext import eu.kanade.tachiyomi.util.prepUpdateCover import eu.kanade.tachiyomi.util.shouldDownloadNewChapters @@ -347,6 +348,9 @@ class LibraryUpdateService( MANGA_NON_READ in restrictions && mangaWithNotif.totalChapters > 0 && !mangaWithNotif.hasStarted -> skippedUpdates.add(mangaWithNotif to getString(R.string.skipped_reason_not_started)) + mangaWithNotif.update_strategy != UpdateStrategy.ALWAYS_UPDATE -> + skippedUpdates.add(mangaWithNotif to getString(R.string.skipped_reason_not_always_update)) + else -> { // Convert to the manga that contains new chapters mangaWithNotif.toDomainManga()?.let { domainManga -> diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt index 5b9d79e0c3..524134e453 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt @@ -38,7 +38,7 @@ internal object ExtensionLoader { private const val METADATA_HAS_README = "tachiyomi.extension.hasReadme" private const val METADATA_HAS_CHANGELOG = "tachiyomi.extension.hasChangelog" const val LIB_VERSION_MIN = 1.2 - const val LIB_VERSION_MAX = 1.3 + const val LIB_VERSION_MAX = 1.4 private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES diff --git a/app/src/main/sqldelight/data/mangas.sq b/app/src/main/sqldelight/data/mangas.sq index 41a5931338..4a5b7bf56b 100644 --- a/app/src/main/sqldelight/data/mangas.sq +++ b/app/src/main/sqldelight/data/mangas.sq @@ -1,3 +1,4 @@ +import eu.kanade.tachiyomi.source.model.UpdateStrategy; import java.lang.String; import kotlin.collections.List; @@ -19,7 +20,8 @@ CREATE TABLE mangas( viewer INTEGER NOT NULL, chapter_flags INTEGER NOT NULL, cover_last_modified INTEGER AS Long NOT NULL, - date_added INTEGER AS Long NOT NULL + date_added INTEGER AS Long NOT NULL, + update_strategy INTEGER AS UpdateStrategy NOT NULL DEFAULT 0 ); CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1; @@ -133,8 +135,8 @@ DELETE FROM mangas WHERE favorite = 0 AND source IN :sourceIds; insert: -INSERT INTO mangas(source,url,artist,author,description,genre,title,status,thumbnail_url,favorite,last_update,next_update,initialized,viewer,chapter_flags,cover_last_modified,date_added) -VALUES (:source,:url,:artist,:author,:description,:genre,:title,:status,:thumbnailUrl,:favorite,:lastUpdate,:nextUpdate,:initialized,:viewerFlags,:chapterFlags,:coverLastModified,:dateAdded); +INSERT INTO mangas(source,url,artist,author,description,genre,title,status,thumbnail_url,favorite,last_update,next_update,initialized,viewer,chapter_flags,cover_last_modified,date_added,update_strategy) +VALUES (:source,:url,:artist,:author,:description,:genre,:title,:status,:thumbnailUrl,:favorite,:lastUpdate,:nextUpdate,:initialized,:viewerFlags,:chapterFlags,:coverLastModified,:dateAdded,:updateStrategy); update: UPDATE mangas SET @@ -153,7 +155,8 @@ UPDATE mangas SET viewer = coalesce(:viewer, viewer), chapter_flags = coalesce(:chapterFlags, chapter_flags), cover_last_modified = coalesce(:coverLastModified, cover_last_modified), - date_added = coalesce(:dateAdded, date_added) + date_added = coalesce(:dateAdded, date_added), + update_strategy = coalesce(:updateStrategy, update_strategy) WHERE _id = :mangaId; selectLastInsertedRowId: diff --git a/app/src/main/sqldelight/migrations/20.sqm b/app/src/main/sqldelight/migrations/20.sqm new file mode 100644 index 0000000000..8c4cc983a6 --- /dev/null +++ b/app/src/main/sqldelight/migrations/20.sqm @@ -0,0 +1 @@ +ALTER TABLE mangas ADD COLUMN update_strategy INTEGER NOT NULL DEFAULT 0; diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 34c2660a73..077d30b5b0 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -801,6 +801,7 @@ Skipped because series is complete Skipped because there are unread chapters Skipped because no chapters are read + Skipped because series does not require updates Select cover image diff --git a/source-api/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt b/source-api/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt index fb1fab4744..f0a014e2a1 100644 --- a/source-api/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt +++ b/source-api/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt @@ -20,6 +20,8 @@ interface SManga : Serializable { var thumbnail_url: String? + var update_strategy: UpdateStrategy + var initialized: Boolean fun getGenres(): List? { @@ -50,6 +52,8 @@ interface SManga : Serializable { status = other.status + update_strategy = other.update_strategy + if (!initialized) { initialized = other.initialized } @@ -64,6 +68,7 @@ interface SManga : Serializable { it.genre = genre it.status = status it.thumbnail_url = thumbnail_url + it.update_strategy = update_strategy it.initialized = initialized } diff --git a/source-api/src/main/java/eu/kanade/tachiyomi/source/model/SMangaImpl.kt b/source-api/src/main/java/eu/kanade/tachiyomi/source/model/SMangaImpl.kt index c944474a13..91a7711cce 100644 --- a/source-api/src/main/java/eu/kanade/tachiyomi/source/model/SMangaImpl.kt +++ b/source-api/src/main/java/eu/kanade/tachiyomi/source/model/SMangaImpl.kt @@ -18,5 +18,7 @@ class SMangaImpl : SManga { override var thumbnail_url: String? = null + override var update_strategy: UpdateStrategy = UpdateStrategy.ALWAYS_UPDATE + override var initialized: Boolean = false } diff --git a/source-api/src/main/java/eu/kanade/tachiyomi/source/model/UpdateStrategy.kt b/source-api/src/main/java/eu/kanade/tachiyomi/source/model/UpdateStrategy.kt new file mode 100644 index 0000000000..95392e3618 --- /dev/null +++ b/source-api/src/main/java/eu/kanade/tachiyomi/source/model/UpdateStrategy.kt @@ -0,0 +1,22 @@ +package eu.kanade.tachiyomi.source.model + +/** + * Define the update strategy for a single [SManga]. + * The strategy used will only take effect on the library update. + * + * @since extensions-lib 1.4 + */ +enum class UpdateStrategy { + /** + * Series marked as always update will be included in the library + * update if they aren't excluded by additional restrictions. + */ + ALWAYS_UPDATE, + + /** + * Series marked as only fetch once will be automatically skipped + * during library updates. Useful for cases where the series is previously + * known to be finished and have only a single chapter, for example. + */ + ONLY_FETCH_ONCE +}