diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 7925fccf8..4f25f85ed 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -90,20 +90,28 @@ object BookHelp { analyzeUrl.getImageBytes(book.origin)?.let { FileUtils.createFileIfNotExist( downloadDir, - "${MD5Utils.md5Encode16(src)}${src.substringAfterLast(".").substringBefore(",")}", + "${MD5Utils.md5Encode16(src)}${getImageSuffix(src)}", subDirs = arrayOf(cacheFolderName, bookFolderName(book), cacheImageFolderName) ).writeBytes(it) } } - - fun getImage(book:Book, src:String): File { + + fun getImage(book: Book, src: String): File { return FileUtils.getFile( downloadDir, - "${MD5Utils.md5Encode16(src)}${src.substringAfterLast(".").substringBefore(",")}", + "${MD5Utils.md5Encode16(src)}${getImageSuffix(src)}", subDirs = arrayOf(cacheFolderName, bookFolderName(book), cacheImageFolderName) ) } + private fun getImageSuffix(src: String): String { + var suffix = src.substringAfterLast(".").substringBefore(",") + if (suffix.length > 5) { + suffix = ".jpg" + } + return suffix + } + fun getChapterFiles(book: Book): List { val fileNameList = arrayListOf() FileUtils.createFolderIfNotExist(