mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-14 08:41:28 +00:00
Start FlatpakUpdater
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -34,10 +34,10 @@
|
||||
|
||||
<!-- cryptomator dependencies -->
|
||||
<cryptomator.cryptofs.version>2.9.0</cryptomator.cryptofs.version>
|
||||
<cryptomator.integrations.version>1.6.0</cryptomator.integrations.version>
|
||||
<cryptomator.integrations.version>1.7.0-SNAPSHOT</cryptomator.integrations.version>
|
||||
<cryptomator.integrations.win.version>1.5.0</cryptomator.integrations.win.version>
|
||||
<cryptomator.integrations.mac.version>1.4.0</cryptomator.integrations.mac.version>
|
||||
<cryptomator.integrations.linux.version>1.6.0</cryptomator.integrations.linux.version>
|
||||
<cryptomator.integrations.linux.version>1.7.0-SNAPSHOT</cryptomator.integrations.linux.version>
|
||||
<cryptomator.fuse.version>5.0.5</cryptomator.fuse.version>
|
||||
<cryptomator.webdav.version>2.0.10</cryptomator.webdav.version>
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.cryptomator.common.updates;
|
||||
|
||||
import org.cryptomator.integrations.update.UpdateFailedException;
|
||||
import org.cryptomator.integrations.update.UpdateService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Optional;
|
||||
|
||||
public class AppUpdateChecker {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AppUpdateChecker.class);
|
||||
private final Optional<UpdateService> updateService;
|
||||
|
||||
@Inject
|
||||
public AppUpdateChecker(Optional<UpdateService> updateService) {
|
||||
this.updateService = updateService;
|
||||
}
|
||||
|
||||
public void checkForUpdates() {
|
||||
updateService.ifPresent(service -> {
|
||||
try {
|
||||
service.triggerUpdate();
|
||||
} catch (UpdateFailedException e) {
|
||||
LOG.error(e.toString(), e.getCause());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import dagger.BindsInstance;
|
||||
import dagger.Component;
|
||||
import org.cryptomator.common.CommonsModule;
|
||||
import org.cryptomator.ui.fxapp.FxApplicationComponent;
|
||||
import org.cryptomator.common.updates.AppUpdateChecker;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
@@ -14,6 +15,8 @@ public interface CryptomatorComponent {
|
||||
|
||||
Cryptomator application();
|
||||
|
||||
AppUpdateChecker appUpdateChecker();
|
||||
|
||||
FxApplicationComponent.Builder fxAppComponentBuilder();
|
||||
|
||||
@Component.Factory
|
||||
|
||||
@@ -5,6 +5,7 @@ import dagger.Provides;
|
||||
import org.cryptomator.integrations.autostart.AutoStartProvider;
|
||||
import org.cryptomator.integrations.tray.TrayIntegrationProvider;
|
||||
import org.cryptomator.integrations.uiappearance.UiAppearanceProvider;
|
||||
import org.cryptomator.integrations.update.UpdateService;
|
||||
import org.cryptomator.ui.fxapp.FxApplicationComponent;
|
||||
|
||||
import javax.inject.Named;
|
||||
@@ -48,4 +49,9 @@ class CryptomatorModule {
|
||||
return TrayIntegrationProvider.get();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static Optional<UpdateService> provideUpdateService() {
|
||||
return UpdateService.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.cryptomator.ui.fxapp;
|
||||
import org.cryptomator.common.Environment;
|
||||
import org.cryptomator.common.SemVerComparator;
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
import org.cryptomator.common.updates.AppUpdateChecker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -36,17 +37,20 @@ public class UpdateChecker {
|
||||
private final Comparator<String> versionComparator = new SemVerComparator();
|
||||
private final BooleanBinding updateAvailable;
|
||||
private final BooleanBinding checkFailed;
|
||||
private final AppUpdateChecker updateChecker;
|
||||
|
||||
@Inject
|
||||
UpdateChecker(Settings settings, //
|
||||
Environment env, //
|
||||
ScheduledService<String> updateCheckerService) {
|
||||
ScheduledService<String> updateCheckerService,
|
||||
AppUpdateChecker updateChecker) {
|
||||
this.env = env;
|
||||
this.settings = settings;
|
||||
this.updateCheckerService = updateCheckerService;
|
||||
this.lastSuccessfulUpdateCheck = settings.lastSuccessfulUpdateCheck;
|
||||
this.updateAvailable = Bindings.createBooleanBinding(this::isUpdateAvailable, latestVersion);
|
||||
this.checkFailed = Bindings.equal(UpdateCheckState.CHECK_FAILED, state);
|
||||
this.updateChecker = updateChecker;
|
||||
}
|
||||
|
||||
public void automaticallyCheckForUpdatesIfEnabled() {
|
||||
@@ -56,7 +60,7 @@ public class UpdateChecker {
|
||||
}
|
||||
|
||||
public void checkForUpdatesNow() {
|
||||
startCheckingForUpdates(Duration.ZERO);
|
||||
updateChecker.checkForUpdates();
|
||||
}
|
||||
|
||||
private void startCheckingForUpdates(Duration initialDelay) {
|
||||
|
||||
Reference in New Issue
Block a user