mirror of
https://github.com/cryptomator/cryptomator.git
synced 2025-02-22 03:11:08 +00:00
created global mountService
This commit is contained in:
parent
c369487e8e
commit
63bf0315c7
@ -21,9 +21,11 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@ -141,4 +143,13 @@ public abstract class CommonsModule {
|
||||
return new AtomicReference<>(null);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static ObservableValue<MountService> provideDefaultMountService(List<MountService> mountProviders, Settings settings) {
|
||||
var fallbackProvider = mountProviders.stream().findFirst().orElse(null);
|
||||
|
||||
return ObservableUtil.mapWithDefault(settings.mountService, //
|
||||
serviceName -> mountProviders.stream().filter(s -> s.getClass().getName().equals(serviceName)).findFirst().orElse(fallbackProvider), //
|
||||
fallbackProvider);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.cryptomator.integrations.mount.MountService;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -30,27 +31,28 @@ public class Mounter {
|
||||
|
||||
private final Environment env;
|
||||
private final WindowsDriveLetters driveLetters;
|
||||
private final Settings settings;
|
||||
private final List<MountService> mountProviders;
|
||||
private final AtomicReference<MountService> firstUsedProblematicFuseMountService;
|
||||
private final ObservableValue<MountService> defaultMountService;
|
||||
|
||||
@Inject
|
||||
public Mounter(Environment env, //
|
||||
WindowsDriveLetters driveLetters, //
|
||||
Settings settings, List<MountService> mountProviders, //
|
||||
@Named("FUPFMS") AtomicReference<MountService> firstUsedProblematicFuseMountService) {
|
||||
List<MountService> mountProviders, //
|
||||
@Named("FUPFMS") AtomicReference<MountService> firstUsedProblematicFuseMountService,
|
||||
ObservableValue<MountService> defaultMountService) {
|
||||
this.env = env;
|
||||
this.driveLetters = driveLetters;
|
||||
this.settings = settings;
|
||||
this.mountProviders = mountProviders;
|
||||
this.firstUsedProblematicFuseMountService = firstUsedProblematicFuseMountService;
|
||||
this.defaultMountService = defaultMountService;
|
||||
}
|
||||
|
||||
private class SettledMounter {
|
||||
|
||||
private MountService service;
|
||||
private MountBuilder builder;
|
||||
private VaultSettings vaultSettings;
|
||||
private final MountService service;
|
||||
private final MountBuilder builder;
|
||||
private final VaultSettings vaultSettings;
|
||||
|
||||
public SettledMounter(MountService service, MountBuilder builder, VaultSettings vaultSettings) {
|
||||
this.service = service;
|
||||
@ -139,9 +141,7 @@ public class Mounter {
|
||||
}
|
||||
|
||||
public MountHandle mount(VaultSettings vaultSettings, Path cryptoFsRoot) throws IOException, MountFailedException {
|
||||
var fallbackProvider = mountProviders.stream().findFirst().orElse(null);
|
||||
var defMntServ = mountProviders.stream().filter(s -> s.getClass().getName().equals(settings.mountService.getValue())).findFirst().orElse(fallbackProvider);
|
||||
var selMntServ = mountProviders.stream().filter(s -> s.getClass().getName().equals(vaultSettings.mountService.getValue())).findFirst().orElse(defMntServ);
|
||||
var selMntServ = mountProviders.stream().filter(s -> s.getClass().getName().equals(vaultSettings.mountService.getValue())).findFirst().orElse(defaultMountService.getValue());
|
||||
|
||||
var targetIsProblematicFuse = isProblematicFuseService(selMntServ);
|
||||
if (targetIsProblematicFuse && firstUsedProblematicFuseMountService.get() == null) {
|
||||
|
@ -2,7 +2,6 @@ package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import dagger.Lazy;
|
||||
import org.cryptomator.common.ObservableUtil;
|
||||
import org.cryptomator.common.mount.Mounter;
|
||||
import org.cryptomator.common.mount.WindowsDriveLetters;
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
@ -88,7 +87,7 @@ public class MountOptionsController implements FxController {
|
||||
ResourceBundle resourceBundle, //
|
||||
Lazy<Application> application, //
|
||||
List<MountService> mountProviders, //
|
||||
@Named("FUPFMS") AtomicReference<MountService> firstUsedProblematicFuseMountService) {
|
||||
@Named("FUPFMS") AtomicReference<MountService> firstUsedProblematicFuseMountService, ObservableValue<MountService> defaultMountService) {
|
||||
this.window = window;
|
||||
this.vaultSettings = vault.getVaultSettings();
|
||||
this.windowsDriveLetters = windowsDriveLetters;
|
||||
@ -96,10 +95,7 @@ public class MountOptionsController implements FxController {
|
||||
this.directoryPath = vault.getVaultSettings().mountPoint.map(p -> isDriveLetter(p) ? null : p.toString());
|
||||
this.application = application;
|
||||
this.mountProviders = mountProviders;
|
||||
var fallbackProvider = mountProviders.stream().findFirst().orElse(null);
|
||||
this.defaultMountService = ObservableUtil.mapWithDefault(settings.mountService, //
|
||||
serviceName -> mountProviders.stream().filter(s -> s.getClass().getName().equals(serviceName)).findFirst().orElse(fallbackProvider), //
|
||||
fallbackProvider);
|
||||
this.defaultMountService = defaultMountService;
|
||||
this.selectedMountService = Bindings.createObjectBinding(this::reselectMountService, defaultMountService, vaultSettings.mountService);
|
||||
this.fuseRestartRequired = selectedMountService.map(s -> {
|
||||
return firstUsedProblematicFuseMountService.get() != null //
|
||||
|
Loading…
x
Reference in New Issue
Block a user