mirror of
https://github.com/null2264/yokai.git
synced 2025-06-20 18:24:42 +00:00
refactor(source/local): Invalidate before getting other manga details
Reduce code duplication and also covers local manga without metadata file
This commit is contained in:
parent
df8eeb8e88
commit
fa1f780b47
1 changed files with 3 additions and 2 deletions
|
@ -196,6 +196,9 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
|||
override suspend fun getLatestUpdates(page: Int) = getSearchManga(page, "", latestFilters)
|
||||
|
||||
override suspend fun getMangaDetails(manga: SManga): SManga = withIOContext {
|
||||
// Making sure that we have the latest cover file path, in case user use different file format
|
||||
invalidateCover(manga)
|
||||
|
||||
try {
|
||||
val localMangaDir = getBaseDirectory()?.findFile(manga.url) ?: throw Exception("${manga.url} is not a valid directory")
|
||||
val localMangaFiles = localMangaDir.listFiles().orEmpty().filter { !it.isDirectory }
|
||||
|
@ -205,14 +208,12 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
|||
if (comicInfoFile != null)
|
||||
return@withIOContext manga.copy().apply {
|
||||
setMangaDetailsFromComicInfoFile(comicInfoFile.openInputStream(), this)
|
||||
invalidateCover(this)
|
||||
}
|
||||
|
||||
// TODO: Remove after awhile
|
||||
if (legacyJsonFile != null) {
|
||||
val rt = manga.copy().apply {
|
||||
setMangaDetailsFromLegacyJsonFile(legacyJsonFile.openInputStream(), this)
|
||||
invalidateCover(this)
|
||||
}
|
||||
val comicInfo = rt.toComicInfo()
|
||||
localMangaDir.createFile(COMIC_INFO_FILE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue