Merge branch 'gedoor:master' into master

pull/1816/head
ag2s20150909 3 years ago committed by GitHub
commit b5cc20ed8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt

@ -25,7 +25,6 @@ import org.mozilla.javascript.WrappedException
import java.io.File
import java.net.ConnectException
import java.net.SocketTimeoutException
import java.util.*
/**
* 在线朗读
@ -269,7 +268,9 @@ class HttpReadAloudService : BaseReadAloudService(),
private fun removeCacheFile() {
val titleMd5 = MD5Utils.md5Encode16(textChapter?.title ?: "")
FileUtils.listDirsAndFiles(ttsFolderPath)?.forEach {
if (!it.name.startsWith(titleMd5) && Date().time - it.lastModified() > 600000) {
if (!it.name.startsWith(titleMd5)
&& System.currentTimeMillis() - it.lastModified() > 600000
) {
FileUtils.delete(it.absolutePath)
}
}

@ -15,7 +15,9 @@ import io.legado.app.model.localBook.EpubFile
import io.legado.app.utils.BitmapUtils
import io.legado.app.utils.FileUtils
import io.legado.app.utils.isXml
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import splitties.init.appCtx
import java.io.File
import java.io.FileOutputStream
@ -59,6 +61,7 @@ object ImageProvider {
src: String,
bookSource: BookSource?
): File {
return withContext(IO) {
val vFile = BookHelp.getImage(book, src)
if (!vFile.exists()) {
if (book.isEpub()) {
@ -73,7 +76,8 @@ object ImageProvider {
BookHelp.saveImage(bookSource, book, src)
}
}
return vFile
return@withContext vFile
}
}
/**

Loading…
Cancel
Save