From 4fb8960fd1de4efd19c3a74421a7434ed1f77a77 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Tue, 9 Jan 2024 07:45:24 +0100 Subject: [PATCH] option to disable update checking Add the command line flag `--disable_updater` to disable all checking for updates. Enabled for now, the gateway is still not yet implemented --- .../de/bixilon/minosoft/terminal/CommandLineArguments.kt | 8 +++++++- .../java/de/bixilon/minosoft/terminal/RunConfiguration.kt | 5 ++++- .../java/de/bixilon/minosoft/updater/MinosoftUpdater.kt | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/terminal/CommandLineArguments.kt b/src/main/java/de/bixilon/minosoft/terminal/CommandLineArguments.kt index f02cdb8b1..f91d7489a 100644 --- a/src/main/java/de/bixilon/minosoft/terminal/CommandLineArguments.kt +++ b/src/main/java/de/bixilon/minosoft/terminal/CommandLineArguments.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2020-2023 Moritz Zwerger + * Copyright (C) 2020-2024 Moritz Zwerger * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -111,6 +111,10 @@ object CommandLineArguments { addArgument("--render-api") .action(Arguments.store()) .help("Render API to use. Defaults to gl") + + addArgument("--disable-updater") + .action(Arguments.store()) + .help("Force disables all update checking") } fun parse(args: Array) { @@ -155,6 +159,8 @@ object CommandLineArguments { setWindowFactory(namespace.getString("window")?.lowercase() ?: "glfw") setRenderApi(namespace.getString("render_api")?.lowercase() ?: "gl") + + RunConfiguration.UPDATE_CHECKING = !namespace.getBoolean("disable_updater") } private fun setWindowFactory(name: String) { diff --git a/src/main/java/de/bixilon/minosoft/terminal/RunConfiguration.kt b/src/main/java/de/bixilon/minosoft/terminal/RunConfiguration.kt index dba47d054..8ef4fa9a4 100644 --- a/src/main/java/de/bixilon/minosoft/terminal/RunConfiguration.kt +++ b/src/main/java/de/bixilon/minosoft/terminal/RunConfiguration.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2020-2023 Moritz Zwerger + * Copyright (C) 2020-2024 Moritz Zwerger * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -34,6 +34,9 @@ object RunConfiguration { var AUTO_CONNECT_TO: String? = null + + var UPDATE_CHECKING = false // TODO: This should be enabled. + var HOME_DIRECTORY: Path = unsafeNull() private set var CONFIG_DIRECTORY: Path = unsafeNull() diff --git a/src/main/java/de/bixilon/minosoft/updater/MinosoftUpdater.kt b/src/main/java/de/bixilon/minosoft/updater/MinosoftUpdater.kt index a5f48aa96..9e29ef01a 100644 --- a/src/main/java/de/bixilon/minosoft/updater/MinosoftUpdater.kt +++ b/src/main/java/de/bixilon/minosoft/updater/MinosoftUpdater.kt @@ -20,6 +20,7 @@ import de.bixilon.kutil.string.StringUtil.formatPlaceholder import de.bixilon.kutil.url.URLUtil.toURL import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager import de.bixilon.minosoft.properties.MinosoftProperties +import de.bixilon.minosoft.terminal.RunConfiguration import de.bixilon.minosoft.util.http.HTTP2.get import de.bixilon.minosoft.util.http.HTTPResponse import de.bixilon.minosoft.util.http.exceptions.HTTPException @@ -44,6 +45,7 @@ object MinosoftUpdater { } fun check(force: Boolean = false, callback: (MinosoftUpdate?) -> Unit) { + if (!RunConfiguration.UPDATE_CHECKING) return if (!MinosoftProperties.canUpdate()) return if (!force) { this.update?.let { callback.invoke(update); return }