From 4622b18c9960e9ca618cbdcba98920350358781c Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 4 Dec 2022 14:00:23 -0500 Subject: [PATCH] Fix local source detail JSON files not being read if .noxml was created Fixes #8549 --- .../eu/kanade/tachiyomi/source/LocalSource.kt | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index 19122761eb..b1a48e6f7a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -152,18 +152,33 @@ class LocalSource( // Augment manga details based on metadata files try { val mangaDirFiles = getMangaDirsFiles(manga.url, baseDirsFile).toList() + val comicInfoFile = mangaDirFiles .firstOrNull { it.name == COMIC_INFO_FILE } val noXmlFile = mangaDirFiles .firstOrNull { it.name == ".noxml" } - if (comicInfoFile != null && noXmlFile != null) noXmlFile.delete() + val legacyJsonDetailsFile = mangaDirFiles + .firstOrNull { it.extension == "json" } when { // Top level ComicInfo.xml comicInfoFile != null -> { + noXmlFile?.delete() setMangaDetailsFromComicInfoFile(comicInfoFile.inputStream(), manga) } + // TODO: automatically convert these to ComicInfo.xml + legacyJsonDetailsFile != null -> { + json.decodeFromStream(legacyJsonDetailsFile.inputStream()).run { + title?.let { manga.title = it } + author?.let { manga.author = it } + artist?.let { manga.artist = it } + description?.let { manga.description = it } + genre?.let { manga.genre = it.joinToString() } + status?.let { manga.status = it } + } + } + // Copy ComicInfo.xml from chapter archive to top level if found noXmlFile == null -> { val chapterArchives = mangaDirFiles @@ -181,22 +196,6 @@ class LocalSource( File("$folderPath/.noxml").createNewFile() } } - - // Fall back to legacy JSON details format - else -> { - mangaDirFiles - .firstOrNull { it.extension == "json" } - ?.let { file -> - json.decodeFromStream(file.inputStream()).run { - title?.let { manga.title = it } - author?.let { manga.author = it } - artist?.let { manga.artist = it } - description?.let { manga.description = it } - genre?.let { manga.genre = it.joinToString() } - status?.let { manga.status = it } - } - } - } } } catch (e: Throwable) { logcat(LogPriority.ERROR, e) { "Error setting manga details from local metadata for ${manga.title}" }