Merge branch 'gedoor:master' into master
This commit is contained in:
@@ -25,7 +25,6 @@ import org.mozilla.javascript.WrappedException
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.ConnectException
|
import java.net.ConnectException
|
||||||
import java.net.SocketTimeoutException
|
import java.net.SocketTimeoutException
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线朗读
|
* 在线朗读
|
||||||
@@ -269,7 +268,9 @@ class HttpReadAloudService : BaseReadAloudService(),
|
|||||||
private fun removeCacheFile() {
|
private fun removeCacheFile() {
|
||||||
val titleMd5 = MD5Utils.md5Encode16(textChapter?.title ?: "")
|
val titleMd5 = MD5Utils.md5Encode16(textChapter?.title ?: "")
|
||||||
FileUtils.listDirsAndFiles(ttsFolderPath)?.forEach {
|
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)
|
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.BitmapUtils
|
||||||
import io.legado.app.utils.FileUtils
|
import io.legado.app.utils.FileUtils
|
||||||
import io.legado.app.utils.isXml
|
import io.legado.app.utils.isXml
|
||||||
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
@@ -59,21 +61,23 @@ object ImageProvider {
|
|||||||
src: String,
|
src: String,
|
||||||
bookSource: BookSource?
|
bookSource: BookSource?
|
||||||
): File {
|
): File {
|
||||||
val vFile = BookHelp.getImage(book, src)
|
return withContext(IO) {
|
||||||
if (!vFile.exists()) {
|
val vFile = BookHelp.getImage(book, src)
|
||||||
if (book.isEpub()) {
|
if (!vFile.exists()) {
|
||||||
EpubFile.getImage(book, src)?.use { input ->
|
if (book.isEpub()) {
|
||||||
val newFile = FileUtils.createFileIfNotExist(vFile.absolutePath)
|
EpubFile.getImage(book, src)?.use { input ->
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
val newFile = FileUtils.createFileIfNotExist(vFile.absolutePath)
|
||||||
FileOutputStream(newFile).use { output ->
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
input.copyTo(output)
|
FileOutputStream(newFile).use { output ->
|
||||||
|
input.copyTo(output)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
BookHelp.saveImage(bookSource, book, src)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
BookHelp.saveImage(bookSource, book, src)
|
|
||||||
}
|
}
|
||||||
|
return@withContext vFile
|
||||||
}
|
}
|
||||||
return vFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user