mirror of
https://github.com/InsanusMokrassar/SauceNaoAPI.git
synced 2024-12-23 05:07:12 +00:00
hotfix
This commit is contained in:
parent
270be95784
commit
69bfa56692
@ -16,8 +16,7 @@ import io.ktor.utils.io.core.Input
|
|||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlin.coroutines.Continuation
|
import kotlin.coroutines.*
|
||||||
import kotlin.coroutines.suspendCoroutine
|
|
||||||
|
|
||||||
private const val API_TOKEN_FIELD = "api_key"
|
private const val API_TOKEN_FIELD = "api_key"
|
||||||
private const val OUTPUT_TYPE_FIELD = "output_type"
|
private const val OUTPUT_TYPE_FIELD = "output_type"
|
||||||
@ -60,7 +59,7 @@ data class SauceNaoAPI(
|
|||||||
launch {
|
launch {
|
||||||
try {
|
try {
|
||||||
val answer = makeRequest(requestBuilder)
|
val answer = makeRequest(requestBuilder)
|
||||||
callback.resumeWith(Result.success(answer))
|
callback.resume(answer)
|
||||||
|
|
||||||
quotaManager.updateQuota(answer.header, timeManager)
|
quotaManager.updateQuota(answer.header, timeManager)
|
||||||
} catch (e: TooManyRequestsException) {
|
} catch (e: TooManyRequestsException) {
|
||||||
@ -68,7 +67,7 @@ data class SauceNaoAPI(
|
|||||||
requestsChannel.send(callback to requestBuilder)
|
requestsChannel.send(callback to requestBuilder)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
try {
|
try {
|
||||||
callback.resumeWith(Result.failure(e))
|
callback.resume(e)
|
||||||
} catch (e: IllegalStateException) { // may happen when already resumed and api was closed
|
} catch (e: IllegalStateException) { // may happen when already resumed and api was closed
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user