From f3ca4e76a8ee10560897e8718267b208ae2cb3c2 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 19 Mar 2023 13:02:38 -0400 Subject: [PATCH] Re-enable ComicInfo.xml generation on download Closes #8537 --- .../tachiyomi/data/download/Downloader.kt | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 81965ba6c..75b199ab7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -545,14 +545,12 @@ class Downloader( } download.status = if (downloadedImagesCount == downloadPageCount) { - // TODO: Uncomment when #8537 is resolved -// val chapterUrl = download.source.getChapterUrl(download.chapter) -// createComicInfoFile( -// tmpDir, -// download.manga, -// download.chapter.toDomainChapter()!!, -// chapterUrl, -// ) + createComicInfoFile( + tmpDir, + download.manga, + download.chapter, + download.source, + ) // Only rename the directory if it's downloaded if (downloadPreferences.saveChaptersAsCBZ().get()) { @@ -606,23 +604,19 @@ class Downloader( /** * Creates a ComicInfo.xml file inside the given directory. - * - * @param dir the directory in which the ComicInfo file will be generated. - * @param manga the manga. - * @param chapter the chapter. - * @param chapterUrl the resolved URL for the chapter. */ private fun createComicInfoFile( dir: UniFile, manga: Manga, chapter: Chapter, - chapterUrl: String, + source: HttpSource, ) { + val chapterUrl = source.getChapterUrl(chapter.toSChapter()) val comicInfo = getComicInfo(manga, chapter, chapterUrl) - val comicInfoString = xml.encodeToString(ComicInfo.serializer(), comicInfo) // Remove the old file dir.findFile(COMIC_INFO_FILE)?.delete() dir.createFile(COMIC_INFO_FILE).openOutputStream().use { + val comicInfoString = xml.encodeToString(ComicInfo.serializer(), comicInfo) it.write(comicInfoString.toByteArray()) } }