Fix potential crash when fetching filters (#11419)
* Comicklive: fix crash on filters * Kagane: fix crash on filters
This commit is contained in:
parent
9f7b11fc57
commit
4c7f5d6a37
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Comick (Unoriginal)'
|
extName = 'Comick (Unoriginal)'
|
||||||
extClass = '.ComickFactory'
|
extClass = '.ComickFactory'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,16 +19,17 @@ import keiyoushi.utils.firstInstanceOrNull
|
|||||||
import keiyoushi.utils.getPreferences
|
import keiyoushi.utils.getPreferences
|
||||||
import keiyoushi.utils.parseAs
|
import keiyoushi.utils.parseAs
|
||||||
import keiyoushi.utils.tryParse
|
import keiyoushi.utils.tryParse
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import okhttp3.CacheControl
|
import okhttp3.CacheControl
|
||||||
|
import okhttp3.Call
|
||||||
|
import okhttp3.Callback
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.brotli.BrotliInterceptor
|
import okhttp3.brotli.BrotliInterceptor
|
||||||
import okhttp3.internal.closeQuietly
|
import okhttp3.internal.closeQuietly
|
||||||
|
import okio.IOException
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
@ -222,11 +223,18 @@ class Comick(
|
|||||||
|
|
||||||
// the cache only request fails if it was not cached already
|
// the cache only request fails if it was not cached already
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
metadataClient.newCall(
|
||||||
metadataClient.newCall(
|
GET("$baseUrl/api/metadata", headers, CacheControl.FORCE_NETWORK),
|
||||||
GET("$baseUrl/api/metadata", headers, CacheControl.FORCE_NETWORK),
|
).enqueue(
|
||||||
).await().closeQuietly()
|
object : Callback {
|
||||||
}
|
override fun onResponse(call: Call, response: Response) {
|
||||||
|
response.closeQuietly()
|
||||||
|
}
|
||||||
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
|
Log.e(name, "Unable to fetch filters", e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
filters.addAll(
|
filters.addAll(
|
||||||
index = 0,
|
index = 0,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Kagane'
|
extName = 'Kagane'
|
||||||
extClass = '.Kagane'
|
extClass = '.Kagane'
|
||||||
extVersionCode = 8
|
extVersionCode = 9
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,13 +30,13 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
|||||||
import keiyoushi.utils.getPreferencesLazy
|
import keiyoushi.utils.getPreferencesLazy
|
||||||
import keiyoushi.utils.parseAs
|
import keiyoushi.utils.parseAs
|
||||||
import keiyoushi.utils.toJsonString
|
import keiyoushi.utils.toJsonString
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.serialization.json.buildJsonObject
|
import kotlinx.serialization.json.buildJsonObject
|
||||||
import kotlinx.serialization.json.put
|
import kotlinx.serialization.json.put
|
||||||
import okhttp3.CacheControl
|
import okhttp3.CacheControl
|
||||||
|
import okhttp3.Call
|
||||||
|
import okhttp3.Callback
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.MediaType.Companion.toMediaType
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
@ -495,11 +495,18 @@ class Kagane : HttpSource(), ConfigurableSource {
|
|||||||
|
|
||||||
// the cache only request fails if it was not cached already
|
// the cache only request fails if it was not cached already
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
metadataClient.newCall(
|
||||||
metadataClient.newCall(
|
GET("$apiUrl/api/v1/metadata", headers, CacheControl.FORCE_NETWORK),
|
||||||
GET("$apiUrl/api/v1/metadata", headers, CacheControl.FORCE_NETWORK),
|
).enqueue(
|
||||||
).await().closeQuietly()
|
object : Callback {
|
||||||
}
|
override fun onResponse(call: Call, response: Response) {
|
||||||
|
response.closeQuietly()
|
||||||
|
}
|
||||||
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
|
Log.e(name, "Failed to fetch filters", e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
filters.addAll(
|
filters.addAll(
|
||||||
index = 0,
|
index = 0,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user