Update github uploader

This commit is contained in:
Him188 2020-09-02 08:13:25 +08:00
parent 88975a5bd4
commit dc82abb745
2 changed files with 10 additions and 7 deletions

View File

@ -149,7 +149,7 @@ object CuiCloud {
@OptIn(ExperimentalContracts::class)
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RESULT_CLASS_IN_RETURN_TYPE")
@kotlin.internal.InlineOnly
internal inline fun <R> retryCatching(n: Int, onFailure: () -> Unit = {}, block: () -> R): Result<R> {
internal inline fun <R> retryCatching(n: Int, onFailure: (Throwable) -> Unit = {}, block: () -> R): Result<R> {
contract {
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
}
@ -164,7 +164,7 @@ internal inline fun <R> retryCatching(n: Int, onFailure: () -> Unit = {}, block:
} catch (e: Throwable) {
}
exception = e
onFailure()
onFailure(e)
}
}
return Result.failure(exception!!)

View File

@ -30,12 +30,12 @@ import java.util.*
internal val Http = HttpClient(CIO) {
engine {
requestTimeout = 600_000
requestTimeout = 6000_000
}
install(HttpTimeout) {
socketTimeoutMillis = 600_000
requestTimeoutMillis = 600_000
connectTimeoutMillis = 600_000
socketTimeoutMillis = 6000_000
requestTimeoutMillis = 6000_000
connectTimeoutMillis = 6000_000
}
}
@ -87,7 +87,10 @@ object GitHub {
val token = getGithubToken(project)
println("token.length=${token.length}")
val url = "https://api.github.com/repos/project-mirai/$repo/contents/$targetFilePath"
retryCatching(100, onFailure = { delay(30_000) }) { // 403 forbidden?
retryCatching(100, onFailure = {
it.printStackTrace()
delay(30_000)
}) { // 403 forbidden?
Http.put<String>("$url?access_token=$token") {
val sha = retryCatching(3, onFailure = { delay(30_000) }) {
getGithubSha(