diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt index ff91c8cf2..2c0b796df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt @@ -138,14 +138,26 @@ class DownloadProvider( * @param chapterScanlator scanlator of the chapter to query */ fun getChapterDirName(chapterName: String, chapterScanlator: String?): String { + val newChapterName = sanitizeChapterName(chapterName) return DiskUtil.buildValidFilename( when { - chapterScanlator.isNullOrBlank().not() -> "${chapterScanlator}_$chapterName" - else -> chapterName + chapterScanlator.isNullOrBlank().not() -> "${chapterScanlator}_$newChapterName" + else -> newChapterName }, ) } + /** + * Return the new name for the chapter (in case it's empty or blank) + * + * @param chapterName the name of the chapter + */ + private fun sanitizeChapterName(chapterName: String): String { + return chapterName.ifBlank { + "Chapter" + } + } + fun isChapterDirNameChanged(oldChapter: Chapter, newChapter: Chapter): Boolean { return oldChapter.name != newChapter.name || oldChapter.scanlator?.takeIf { it.isNotBlank() } != newChapter.scanlator?.takeIf { it.isNotBlank() }