mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 07:20:04 -04:00
properly warn if update checking failed
This commit is contained in:
parent
f61a6a5981
commit
d77bb34162
@ -68,7 +68,7 @@ class AboutController : EmbeddedJavaFXController<HBox>() {
|
||||
checkUpdatesFX.isDisable = true
|
||||
DefaultThreadPool += {
|
||||
try {
|
||||
val update = MinosoftUpdater.check()
|
||||
val update = MinosoftUpdater.check(error = true)
|
||||
if (update == null) {
|
||||
InfoDialog(i18n("updater.none.title"), i18n("updater.none.header")).show()
|
||||
}
|
||||
|
@ -54,13 +54,13 @@ object MinosoftUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
fun check(): MinosoftUpdate? {
|
||||
fun check(error: Boolean = false): MinosoftUpdate? {
|
||||
val profile = OtherProfileManager.selected.updater
|
||||
return check(profile.url, profile.channel)
|
||||
return check(profile.url, profile.channel, error)
|
||||
}
|
||||
|
||||
|
||||
fun check(url: String, channel: String): MinosoftUpdate? {
|
||||
fun check(url: String, channel: String, error: Boolean): MinosoftUpdate? {
|
||||
val commit = MinosoftProperties.git?.commit ?: ""
|
||||
val version = MinosoftProperties.general.name
|
||||
val stable = MinosoftProperties.general.stable
|
||||
@ -77,17 +77,18 @@ object MinosoftUpdater {
|
||||
)
|
||||
|
||||
validateURL(request.toURL())
|
||||
val update = request(request)
|
||||
val update = request(request, error)
|
||||
this.update = update
|
||||
return update
|
||||
}
|
||||
|
||||
private fun request(url: String): MinosoftUpdate? {
|
||||
private fun request(url: String, error: Boolean): MinosoftUpdate? {
|
||||
val response: HTTPResponse<String>
|
||||
try {
|
||||
response = url.get({ it })
|
||||
} catch (error: Throwable) {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.WARN) { "Could not check for updates: $error" }
|
||||
} catch (exception: Throwable) {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.WARN) { "Could not check for updates: $exception" }
|
||||
if (error) throw exception
|
||||
return null
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user