Pupil-78 Shorten the timout when hiyobi is down
This commit is contained in:
@@ -39,6 +39,7 @@ import java.io.File
|
|||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
import java.util.*
|
||||||
import java.util.concurrent.locks.Lock
|
import java.util.concurrent.locks.Lock
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
|
|
||||||
@@ -166,8 +167,8 @@ class Cache(context: Context) : ContextWrapper(context) {
|
|||||||
val mirrors = preference.getString("mirrors", null)?.split('>') ?: listOf()
|
val mirrors = preference.getString("mirrors", null)?.split('>') ?: listOf()
|
||||||
|
|
||||||
val sources = mapOf(
|
val sources = mapOf(
|
||||||
Code.HITOMI to { xyz.quaver.hitomi.getReader(galleryID) },
|
Code.HITOMI to { Log.i("PUPILD", "READER - HITOMI"); xyz.quaver.hitomi.getReader(galleryID) },
|
||||||
Code.HIYOBI to { xyz.quaver.hiyobi.getReader(galleryID) }
|
Code.HIYOBI to { Log.i("PUPILD", "READER - HIYOBI"); xyz.quaver.hiyobi.getReader(galleryID) }
|
||||||
).let {
|
).let {
|
||||||
if (mirrors.isNotEmpty())
|
if (mirrors.isNotEmpty())
|
||||||
it.toSortedMap(
|
it.toSortedMap(
|
||||||
@@ -180,12 +181,15 @@ class Cache(context: Context) : ContextWrapper(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val reader = if (metadata?.reader == null) {
|
val reader = if (metadata?.reader == null) {
|
||||||
CoroutineScope(Dispatchers.IO).async {
|
|
||||||
var retval: Reader? = null
|
var retval: Reader? = null
|
||||||
|
|
||||||
for (source in sources) {
|
for (source in sources) {
|
||||||
retval = try {
|
retval = try {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
withTimeoutOrNull(1000) {
|
||||||
source.value.invoke()
|
source.value.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
FirebaseCrashlytics.getInstance().recordException(e)
|
FirebaseCrashlytics.getInstance().recordException(e)
|
||||||
null
|
null
|
||||||
@@ -196,7 +200,6 @@ class Cache(context: Context) : ContextWrapper(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
retval
|
retval
|
||||||
}.await() ?: return null
|
|
||||||
} else
|
} else
|
||||||
metadata.reader
|
metadata.reader
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user