mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package io.legado.app.help.update
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import java.time.Instant
|
||||
|
||||
data class AppReleaseInfo(
|
||||
@@ -33,10 +34,10 @@ data class GithubRelease(
|
||||
val isPreRelease: Boolean,
|
||||
) {
|
||||
fun gitReleaseToAppReleaseInfo(): List<AppReleaseInfo> {
|
||||
assets ?: throw NoStackTraceException("获取新版本出错")
|
||||
return assets
|
||||
?.filter { it.isValid }
|
||||
?.map { it.assetToAppReleaseInfo(isPreRelease, body) }
|
||||
.orEmpty()
|
||||
.filter { it.isValid }
|
||||
.map { it.assetToAppReleaseInfo(isPreRelease, body) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,9 @@ import io.legado.app.constant.AppConst
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.help.http.newCallStrResponse
|
||||
import io.legado.app.help.http.newCallResponse
|
||||
import io.legado.app.help.http.okHttpClient
|
||||
import io.legado.app.help.http.text
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.fromJsonObject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -29,9 +30,13 @@ object AppUpdateGitHub : AppUpdate.AppUpdateInterface {
|
||||
} else {
|
||||
"https://api.github.com/repos/gedoor/legado/releases/latest"
|
||||
}
|
||||
val body = okHttpClient.newCallStrResponse {
|
||||
val res = okHttpClient.newCallResponse {
|
||||
url(lastReleaseUrl)
|
||||
}.body
|
||||
}
|
||||
if (!res.isSuccessful) {
|
||||
throw NoStackTraceException("获取新版本出错(${res.code})")
|
||||
}
|
||||
val body = res.body?.text()
|
||||
if (body.isNullOrBlank()) {
|
||||
throw NoStackTraceException("获取新版本出错")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user