kunfei 4 лет назад
Родитель
Сommit
77ef97c072

+ 4 - 4
app/src/main/java/io/legado/app/help/source/BookSourceExtensions.kt

@@ -17,12 +17,12 @@ private val mutexMap by lazy { hashMapOf<String, Mutex>() }
 private val exploreKindsMap by lazy { ConcurrentHashMap<String, List<ExploreKind>>() }
 private val aCache by lazy { ACache.get("explore") }
 
-private fun BookSource.exploreKindsKey(): String {
+private fun BookSource.getExploreKindsKey(): String {
     return MD5Utils.md5Encode(bookSourceUrl + exploreUrl)
 }
 
 suspend fun BookSource.exploreKinds(): List<ExploreKind> {
-    val exploreKindsKey = exploreKindsKey()
+    val exploreKindsKey = getExploreKindsKey()
     exploreKindsMap[exploreKindsKey]?.let { return it }
     val exploreUrl = exploreUrl
     if (exploreUrl.isNullOrBlank()) {
@@ -30,7 +30,7 @@ suspend fun BookSource.exploreKinds(): List<ExploreKind> {
     }
     val mutex = mutexMap[bookSourceUrl] ?: Mutex().apply { mutexMap[bookSourceUrl] = this }
     mutex.withLock {
-        exploreKindsMap[exploreKindsKey()]?.let { return it }
+        exploreKindsMap[exploreKindsKey]?.let { return it }
         val kinds = arrayListOf<ExploreKind>()
         var ruleStr: String = exploreUrl
         withContext(Dispatchers.IO) {
@@ -72,6 +72,6 @@ suspend fun BookSource.exploreKinds(): List<ExploreKind> {
 suspend fun BookSource.clearExploreKindsCache() {
     withContext(Dispatchers.IO) {
         aCache.remove(bookSourceUrl)
-        exploreKindsMap.remove(exploreKindsKey())
+        exploreKindsMap.remove(getExploreKindsKey())
     }
 }

+ 3 - 3
app/src/main/java/io/legado/app/help/source/RssSourceExtensions.kt

@@ -8,13 +8,13 @@ import kotlinx.coroutines.withContext
 
 private val aCache by lazy { ACache.get("rssSortUrl") }
 
-private fun RssSource.sortUrlsKey(): String {
+private fun RssSource.getSortUrlsKey(): String {
     return MD5Utils.md5Encode(sourceUrl + sortUrl)
 }
 
 suspend fun RssSource.sortUrls(): List<Pair<String, String>> =
     arrayListOf<Pair<String, String>>().apply {
-        val sortUrlsKey = sortUrlsKey()
+        val sortUrlsKey = getSortUrlsKey()
         withContext(Dispatchers.IO) {
             kotlin.runCatching {
                 var a = sortUrl
@@ -46,6 +46,6 @@ suspend fun RssSource.sortUrls(): List<Pair<String, String>> =
 
 suspend fun RssSource.removeSortCache() {
     withContext(Dispatchers.IO) {
-        aCache.remove(sortUrlsKey())
+        aCache.remove(getSortUrlsKey())
     }
 }