Migrate things to use newer data models (#9239)
* Remove old database models from Coil * Remove old database models from TrackInfoDialogHome * Remove old database models from Backup Manager
This commit is contained in:
@@ -12,7 +12,6 @@ import coil.request.Options
|
||||
import coil.request.Parameters
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher.Companion.USE_CUSTOM_COVER
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.network.await
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import logcat.LogPriority
|
||||
@@ -26,11 +25,11 @@ import okio.Source
|
||||
import okio.buffer
|
||||
import okio.sink
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaCover
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
import tachiyomi.domain.manga.model.Manga as DomainManga
|
||||
|
||||
/**
|
||||
* A [Fetcher] that fetches cover image for [Manga] object.
|
||||
@@ -261,7 +260,7 @@ class MangaCoverFetcher(
|
||||
File, URL
|
||||
}
|
||||
|
||||
class Factory(
|
||||
class MangaFactory(
|
||||
private val callFactoryLazy: Lazy<Call.Factory>,
|
||||
private val diskCacheLazy: Lazy<DiskCache>,
|
||||
) : Fetcher.Factory<Manga> {
|
||||
@@ -270,36 +269,13 @@ class MangaCoverFetcher(
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
|
||||
override fun create(data: Manga, options: Options, imageLoader: ImageLoader): Fetcher {
|
||||
return MangaCoverFetcher(
|
||||
url = data.thumbnail_url,
|
||||
isLibraryManga = data.favorite,
|
||||
options = options,
|
||||
coverFileLazy = lazy { coverCache.getCoverFile(data.thumbnail_url) },
|
||||
customCoverFileLazy = lazy { coverCache.getCustomCoverFile(data.id) },
|
||||
diskCacheKeyLazy = lazy { MangaKeyer().key(data, options) },
|
||||
sourceLazy = lazy { sourceManager.get(data.source) as? HttpSource },
|
||||
callFactoryLazy = callFactoryLazy,
|
||||
diskCacheLazy = diskCacheLazy,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class DomainMangaFactory(
|
||||
private val callFactoryLazy: Lazy<Call.Factory>,
|
||||
private val diskCacheLazy: Lazy<DiskCache>,
|
||||
) : Fetcher.Factory<DomainManga> {
|
||||
|
||||
private val coverCache: CoverCache by injectLazy()
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
|
||||
override fun create(data: DomainManga, options: Options, imageLoader: ImageLoader): Fetcher {
|
||||
return MangaCoverFetcher(
|
||||
url = data.thumbnailUrl,
|
||||
isLibraryManga = data.favorite,
|
||||
options = options,
|
||||
coverFileLazy = lazy { coverCache.getCoverFile(data.thumbnailUrl) },
|
||||
customCoverFileLazy = lazy { coverCache.getCustomCoverFile(data.id) },
|
||||
diskCacheKeyLazy = lazy { DomainMangaKeyer().key(data, options) },
|
||||
diskCacheKeyLazy = lazy { MangaKeyer().key(data, options) },
|
||||
sourceLazy = lazy { sourceManager.get(data.source) as? HttpSource },
|
||||
callFactoryLazy = callFactoryLazy,
|
||||
diskCacheLazy = diskCacheLazy,
|
||||
|
||||
@@ -4,24 +4,12 @@ import coil.key.Keyer
|
||||
import coil.request.Options
|
||||
import eu.kanade.domain.manga.model.hasCustomCover
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
||||
import tachiyomi.domain.manga.model.MangaCover
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import tachiyomi.domain.manga.model.Manga as DomainManga
|
||||
|
||||
class MangaKeyer : Keyer<Manga> {
|
||||
override fun key(data: Manga, options: Options): String {
|
||||
return if (data.toDomainManga()!!.hasCustomCover()) {
|
||||
"${data.id};${data.cover_last_modified}"
|
||||
} else {
|
||||
"${data.thumbnail_url};${data.cover_last_modified}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DomainMangaKeyer : Keyer<DomainManga> {
|
||||
class MangaKeyer : Keyer<DomainManga> {
|
||||
override fun key(data: DomainManga, options: Options): String {
|
||||
return if (data.hasCustomCover()) {
|
||||
"${data.id};${data.coverLastModified}"
|
||||
@@ -31,9 +19,11 @@ class DomainMangaKeyer : Keyer<DomainManga> {
|
||||
}
|
||||
}
|
||||
|
||||
class MangaCoverKeyer : Keyer<MangaCover> {
|
||||
class MangaCoverKeyer(
|
||||
private val coverCache: CoverCache = Injekt.get(),
|
||||
) : Keyer<MangaCover> {
|
||||
override fun key(data: MangaCover, options: Options): String {
|
||||
return if (Injekt.get<CoverCache>().getCustomCoverFile(data.mangaId).exists()) {
|
||||
return if (coverCache.getCustomCoverFile(data.mangaId).exists()) {
|
||||
"${data.mangaId};${data.lastModified}"
|
||||
} else {
|
||||
"${data.url};${data.lastModified}"
|
||||
|
||||
Reference in New Issue
Block a user