Re-enable ComicInfo.xml generation on download

Closes #8537
This commit is contained in:
arkon 2023-03-19 13:02:38 -04:00
parent 2769525b2c
commit f3ca4e76a8

View File

@ -545,14 +545,12 @@ class Downloader(
} }
download.status = if (downloadedImagesCount == downloadPageCount) { download.status = if (downloadedImagesCount == downloadPageCount) {
// TODO: Uncomment when #8537 is resolved createComicInfoFile(
// val chapterUrl = download.source.getChapterUrl(download.chapter) tmpDir,
// createComicInfoFile( download.manga,
// tmpDir, download.chapter,
// download.manga, download.source,
// download.chapter.toDomainChapter()!!, )
// chapterUrl,
// )
// Only rename the directory if it's downloaded // Only rename the directory if it's downloaded
if (downloadPreferences.saveChaptersAsCBZ().get()) { if (downloadPreferences.saveChaptersAsCBZ().get()) {
@ -606,23 +604,19 @@ class Downloader(
/** /**
* Creates a ComicInfo.xml file inside the given directory. * 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( private fun createComicInfoFile(
dir: UniFile, dir: UniFile,
manga: Manga, manga: Manga,
chapter: Chapter, chapter: Chapter,
chapterUrl: String, source: HttpSource,
) { ) {
val chapterUrl = source.getChapterUrl(chapter.toSChapter())
val comicInfo = getComicInfo(manga, chapter, chapterUrl) val comicInfo = getComicInfo(manga, chapter, chapterUrl)
val comicInfoString = xml.encodeToString(ComicInfo.serializer(), comicInfo)
// Remove the old file // Remove the old file
dir.findFile(COMIC_INFO_FILE)?.delete() dir.findFile(COMIC_INFO_FILE)?.delete()
dir.createFile(COMIC_INFO_FILE).openOutputStream().use { dir.createFile(COMIC_INFO_FILE).openOutputStream().use {
val comicInfoString = xml.encodeToString(ComicInfo.serializer(), comicInfo)
it.write(comicInfoString.toByteArray()) it.write(comicInfoString.toByteArray())
} }
} }