From c5d6c0ce9839ad620098c8049614d81a874780a0 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 18 Sep 2023 13:03:09 +0200 Subject: [PATCH 1/2] add `cryptomator.disableUpdateCheck` property --- .../java/org/cryptomator/common/Environment.java | 6 ++++++ .../java/org/cryptomator/ui/fxapp/FxApplication.java | 9 +++++++-- .../java/org/cryptomator/ui/fxapp/UpdateChecker.java | 12 ++++++------ .../ui/preferences/PreferencesController.java | 8 +++++++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/cryptomator/common/Environment.java b/src/main/java/org/cryptomator/common/Environment.java index 17816df96..981b3729b 100644 --- a/src/main/java/org/cryptomator/common/Environment.java +++ b/src/main/java/org/cryptomator/common/Environment.java @@ -32,6 +32,7 @@ public class Environment { private static final String BUILD_NUMBER_PROP_NAME = "cryptomator.buildNumber"; private static final String PLUGIN_DIR_PROP_NAME = "cryptomator.pluginDir"; private static final String TRAY_ICON_PROP_NAME = "cryptomator.showTrayIcon"; + private static final String DISABLE_UPDATE_CHECK_PROP_NAME = "cryptomator.disableUpdateCheck"; private Environment() {} @@ -53,6 +54,7 @@ public class Environment { logCryptomatorSystemProperty(BUILD_NUMBER_PROP_NAME); logCryptomatorSystemProperty(PLUGIN_DIR_PROP_NAME); logCryptomatorSystemProperty(TRAY_ICON_PROP_NAME); + logCryptomatorSystemProperty(DISABLE_UPDATE_CHECK_PROP_NAME); } public static Environment getInstance() { @@ -124,6 +126,10 @@ public class Environment { return Boolean.getBoolean(TRAY_ICON_PROP_NAME); } + public boolean disableUpdateCheck() { + return Boolean.getBoolean(DISABLE_UPDATE_CHECK_PROP_NAME); + } + private Optional getPath(String propertyName) { String value = System.getProperty(propertyName); return Optional.ofNullable(value).map(Paths::get); diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java index d845655cf..711a0fa44 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.fxapp; import dagger.Lazy; +import org.cryptomator.common.Environment; import org.cryptomator.common.settings.Settings; import org.cryptomator.ui.traymenu.TrayMenuComponent; import org.slf4j.Logger; @@ -17,6 +18,7 @@ public class FxApplication { private static final Logger LOG = LoggerFactory.getLogger(FxApplication.class); private final long startupTime; + private final Environment environment; private final Settings settings; private final AppLaunchEventHandler launchEventHandler; private final Lazy trayMenu; @@ -26,8 +28,9 @@ public class FxApplication { private final AutoUnlocker autoUnlocker; @Inject - FxApplication(@Named("startupTime") long startupTime, Settings settings, AppLaunchEventHandler launchEventHandler, Lazy trayMenu, FxApplicationWindows appWindows, FxApplicationStyle applicationStyle, FxApplicationTerminator applicationTerminator, AutoUnlocker autoUnlocker) { + FxApplication(@Named("startupTime") long startupTime, Environment environment, Settings settings, AppLaunchEventHandler launchEventHandler, Lazy trayMenu, FxApplicationWindows appWindows, FxApplicationStyle applicationStyle, FxApplicationTerminator applicationTerminator, AutoUnlocker autoUnlocker) { this.startupTime = startupTime; + this.environment = environment; this.settings = settings; this.launchEventHandler = launchEventHandler; this.trayMenu = trayMenu; @@ -68,7 +71,9 @@ public class FxApplication { return null; }); - appWindows.checkAndShowUpdateReminderWindow(); + if (!environment.disableUpdateCheck()) { + appWindows.checkAndShowUpdateReminderWindow(); + } launchEventHandler.startHandlingLaunchEvents(); autoUnlocker.tryUnlockForTimespan(2, TimeUnit.MINUTES); diff --git a/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java b/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java index 4418f79b5..709eb2fe7 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java +++ b/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java @@ -22,23 +22,23 @@ public class UpdateChecker { private static final Logger LOG = LoggerFactory.getLogger(UpdateChecker.class); private static final Duration AUTOCHECK_DELAY = Duration.seconds(5); + private final Environment env; private final Settings settings; - private final String currentVersion; private final StringProperty latestVersionProperty; private final Comparator semVerComparator; private final ScheduledService updateCheckerService; @Inject UpdateChecker(Settings settings, Environment env, @Named("latestVersion") StringProperty latestVersionProperty, @Named("SemVer") Comparator semVerComparator, ScheduledService updateCheckerService) { + this.env = env; this.settings = settings; this.latestVersionProperty = latestVersionProperty; this.semVerComparator = semVerComparator; this.updateCheckerService = updateCheckerService; - this.currentVersion = env.getAppVersion(); } public void automaticallyCheckForUpdatesIfEnabled() { - if (settings.checkForUpdates.get()) { + if (!env.disableUpdateCheck() && settings.checkForUpdates.get()) { startCheckingForUpdates(AUTOCHECK_DELAY); } } @@ -63,9 +63,9 @@ public class UpdateChecker { private void checkSucceeded(WorkerStateEvent event) { String latestVersion = updateCheckerService.getValue(); - LOG.info("Current version: {}, lastest version: {}", currentVersion, latestVersion); + LOG.info("Current version: {}, lastest version: {}", getCurrentVersion(), latestVersion); - if (semVerComparator.compare(currentVersion, latestVersion) < 0) { + if (semVerComparator.compare(getCurrentVersion(), latestVersion) < 0) { // update is available latestVersionProperty.set(latestVersion); } else { @@ -88,7 +88,7 @@ public class UpdateChecker { } public String getCurrentVersion() { - return currentVersion; + return env.getAppVersion(); } } diff --git a/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java index caaaf7d80..0937fccd9 100644 --- a/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java @@ -1,5 +1,6 @@ package org.cryptomator.ui.preferences; +import org.cryptomator.common.Environment; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.fxapp.UpdateChecker; import org.slf4j.Logger; @@ -19,6 +20,7 @@ public class PreferencesController implements FxController { private static final Logger LOG = LoggerFactory.getLogger(PreferencesController.class); + private final Environment env; private final Stage window; private final ObjectProperty selectedTabProperty; private final BooleanBinding updateAvailable; @@ -31,7 +33,8 @@ public class PreferencesController implements FxController { public Tab aboutTab; @Inject - public PreferencesController(@PreferencesWindow Stage window, ObjectProperty selectedTabProperty, UpdateChecker updateChecker) { + public PreferencesController(Environment env, @PreferencesWindow Stage window, ObjectProperty selectedTabProperty, UpdateChecker updateChecker) { + this.env = env; this.window = window; this.selectedTabProperty = selectedTabProperty; this.updateAvailable = updateChecker.latestVersionProperty().isNotNull(); @@ -42,6 +45,9 @@ public class PreferencesController implements FxController { window.setOnShowing(this::windowWillAppear); selectedTabProperty.addListener(observable -> this.selectChosenTab()); tabPane.getSelectionModel().selectedItemProperty().addListener(observable -> this.selectedTabChanged()); + if (env.disableUpdateCheck()) { + tabPane.getTabs().remove(updatesTab); + } } private void selectChosenTab() { From 47bd0ca64738e6b218b4ba81af4be788d252b11d Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 18 Sep 2023 13:10:19 +0200 Subject: [PATCH 2/2] disable update check for PPA builds --- .github/workflows/debian.yml | 3 ++- dist/linux/debian/rules | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml index 14cdca80a..2ae6c3262 100644 --- a/.github/workflows/debian.yml +++ b/.github/workflows/debian.yml @@ -97,7 +97,8 @@ jobs: run: | cp -r dist/linux/debian/ pkgdir export RFC2822_TIMESTAMP=`date --rfc-2822` - envsubst '${SEMVER_STR} ${VERSION_NUM} ${REVISION_NUM}' < dist/linux/debian/rules > pkgdir/debian/rules + export DISABLE_UPDATE_CHECK=${{ inputs.dput }} + envsubst '${SEMVER_STR} ${VERSION_NUM} ${REVISION_NUM} ${DISABLE_UPDATE_CHECK}' < dist/linux/debian/rules > pkgdir/debian/rules envsubst '${PPA_VERSION} ${RFC2822_TIMESTAMP}' < dist/linux/debian/changelog > pkgdir/debian/changelog find . -name "*.jar" >> pkgdir/debian/source/include-binaries mv pkgdir cryptomator_${{ inputs.ppaver }} diff --git a/dist/linux/debian/rules b/dist/linux/debian/rules index 231f2a1d5..c12879025 100755 --- a/dist/linux/debian/rules +++ b/dist/linux/debian/rules @@ -59,6 +59,7 @@ override_dh_auto_build: --java-options "-Dcryptomator.integrationsLinux.trayIconsDir=\"/usr/share/icons/hicolor/symbolic/apps\"" \ --java-options "-Dcryptomator.buildNumber=\"deb-${REVISION_NUM}\"" \ --java-options "-Dcryptomator.appVersion=\"${SEMVER_STR}\"" \ + --java-options "-Dcryptomator.disableUpdateCheck=\"${DISABLE_UPDATE_CHECK}\"" \ --app-version "${VERSION_NUM}.${REVISION_NUM}" \ --resource-dir resources \ --verbose