Merge remote-tracking branch 'origin/master'

This commit is contained in:
kunfei
2023-03-25 16:09:51 +08:00

View File

@@ -197,14 +197,17 @@ interface JsExtensions : JsEncodeUtils {
*/
fun cacheFile(urlStr: String, saveTime: Int): String {
val key = md5Encode16(urlStr)
val cahcePath = CacheManager.get(key)
return if (cahcePath.isNullOrBlank()) {
val cachePath = CacheManager.get(key)
return if (
cachePath.isNullOrBlank() ||
!getFile(cachePath).exists()
) {
val path = downloadFile(urlStr)
log("首次下载 $urlStr >> $path")
CacheManager.put(key, path, saveTime)
readTxtFile(path)
} else {
readTxtFile(cahcePath)
readTxtFile(cachePath)
}
}