cacheFile:首次下没有返回下载内容;ACache:saveTime=0视为永久保存

pull/1502/head
Xwite 3 years ago
parent 61708f1e1c
commit 8211f73b43
  1. 5
      app/src/main/java/io/legado/app/help/CacheManager.kt
  2. 4
      app/src/main/java/io/legado/app/utils/ACache.kt

@ -29,10 +29,7 @@ object CacheManager {
} }
fun putString2File(key: String, value: String, saveTime: Int = 0) { fun putString2File(key: String, value: String, saveTime: Int = 0) {
if (saveTime == 0) { ACache.get(appCtx).put(key, value, saveTime)
//不设置过期时间
ACache.get(appCtx).put(key, value)
} else ACache.get(appCtx).put(key, value, saveTime)
} }
fun get(key: String): String? { fun get(key: String): String? {

@ -109,7 +109,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
* @param saveTime 保存的时间单位 * @param saveTime 保存的时间单位
*/ */
fun put(key: String, value: String, saveTime: Int) { fun put(key: String, value: String, saveTime: Int) {
put(key, Utils.newStringWithDateInfo(saveTime, value)) if (saveTime == 0) put(key, value) else put(key, Utils.newStringWithDateInfo(saveTime, value))
} }
/** /**
@ -245,7 +245,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
* @param saveTime 保存的时间单位 * @param saveTime 保存的时间单位
*/ */
fun put(key: String, value: ByteArray, saveTime: Int) { fun put(key: String, value: ByteArray, saveTime: Int) {
put(key, Utils.newByteArrayWithDateInfo(saveTime, value)) if (saveTime == 0) put(key, value) else put(key, Utils.newByteArrayWithDateInfo(saveTime, value))
} }
/** /**

Loading…
Cancel
Save