修复File name too long

pull/346/head
gedoor 4 years ago
parent 949c789f9e
commit 0e88541771
  1. 14
      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<String> {
val fileNameList = arrayListOf<String>()
FileUtils.createFolderIfNotExist(

Loading…
Cancel
Save