This commit is contained in:
Armin Schrenk
2020-11-05 11:52:38 +01:00
parent c01dd225c9
commit f64144d1da
6 changed files with 11 additions and 12 deletions

View File

@@ -46,7 +46,7 @@ public class TemporaryMountPointChooser implements MountPointChooser {
}
private Path choose(Path parent) {
String basename = this.vaultSettings.displayName().get();
String basename = this.vaultSettings.mountName().get();
//regular
Path mountPoint = parent.resolve(basename);
if (Files.notExists(mountPoint)) {

View File

@@ -54,11 +54,11 @@ public class VaultSettings {
private final IntegerProperty filenameLengthLimit = new SimpleIntegerProperty(DEFAULT_FILENAME_LENGTH_LIMIT);
private final ObjectProperty<WhenUnlocked> actionAfterUnlock = new SimpleObjectProperty<>(DEFAULT_ACTION_AFTER_UNLOCK);
private final StringBinding normalizedDisplayName;
private final StringBinding mountName;
public VaultSettings(String id) {
this.id = Objects.requireNonNull(id);
this.normalizedDisplayName = Bindings.createStringBinding(this::normalizeDisplayName, displayName);
this.mountName = Bindings.createStringBinding(this::normalizeDisplayName, displayName);
}
Observable[] observables() {
@@ -107,8 +107,8 @@ public class VaultSettings {
return displayName;
}
public StringBinding normalizedDisplayName() {
return normalizedDisplayName;
public StringBinding mountName() {
return mountName;
}
public StringProperty winDriveLetter() {

View File

@@ -44,7 +44,7 @@ public class DokanyVolume extends AbstractVolume {
this.mountPoint = determineMountPoint();
String mountName = vaultSettings.displayName().get();
try {
this.mount = mountFactory.mount(fs.getPath("/"), mountPoint, vaultSettings.displayName().get(), FS_TYPE_NAME, mountFlags.strip());
this.mount = mountFactory.mount(fs.getPath("/"), mountPoint, vaultSettings.mountName().get(), FS_TYPE_NAME, mountFlags.strip());
} catch (MountFailedException e) {
if (vaultSettings.getCustomMountPath().isPresent()) {
LOG.warn("Failed to mount vault into {}. Is this directory currently accessed by another process (e.g. Windows Explorer)?", mountPoint);

View File

@@ -23,7 +23,6 @@ import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.StringProperty;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -76,7 +75,7 @@ public class VaultModule {
@DefaultMountFlags
public StringBinding provideDefaultMountFlags(Settings settings, VaultSettings vaultSettings) {
ObjectProperty<VolumeImpl> preferredVolumeImpl = settings.preferredVolumeImpl();
StringProperty mountName = vaultSettings.displayName();
StringBinding mountName = vaultSettings.mountName();
BooleanProperty readOnly = vaultSettings.usesReadOnlyMode();
return Bindings.createStringBinding(() -> {
@@ -96,7 +95,7 @@ public class VaultModule {
}
// see: https://github.com/osxfuse/osxfuse/wiki/Mount-options
private String getMacFuseDefaultMountFlags(StringProperty mountName, ReadOnlyBooleanProperty readOnly) {
private String getMacFuseDefaultMountFlags(StringBinding mountName, ReadOnlyBooleanProperty readOnly) {
assert SystemUtils.IS_OS_MAC_OSX;
StringBuilder flags = new StringBuilder();
if (readOnly.get()) {
@@ -148,7 +147,7 @@ public class VaultModule {
// see https://github.com/billziss-gh/winfsp/blob/5d0b10d0b643652c00ebb4704dc2bb28e7244973/src/dll/fuse/fuse_main.c#L53-L62 for syntax guide
// see https://github.com/billziss-gh/winfsp/blob/5d0b10d0b643652c00ebb4704dc2bb28e7244973/src/dll/fuse/fuse.c#L295-L319 for options (-o <...>)
// see https://github.com/billziss-gh/winfsp/wiki/Frequently-Asked-Questions/5ba00e4be4f5e938eaae6ef1500b331de12dee77 (FUSE 4.) on why the given defaults were choosen
private String getWindowsFuseDefaultMountFlags(StringProperty mountName, ReadOnlyBooleanProperty readOnly) {
private String getWindowsFuseDefaultMountFlags(StringBinding mountName, ReadOnlyBooleanProperty readOnly) {
assert SystemUtils.IS_OS_WINDOWS;
StringBuilder flags = new StringBuilder();

View File

@@ -45,7 +45,7 @@ public class WebDavVolume implements Volume {
if (!server.isRunning()) {
server.start();
}
servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.normalizedDisplayName().get());
servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.mountName().get());
servlet.start();
mount();
}

View File

@@ -29,7 +29,7 @@ public class VaultModuleTest {
@BeforeEach
public void setup(@TempDir Path tmpDir) {
Mockito.when(vaultSettings.normalizedDisplayName()).thenReturn(Bindings.createStringBinding(() -> "TEST"));
Mockito.when(vaultSettings.mountName()).thenReturn(Bindings.createStringBinding(() -> "TEST"));
Mockito.when(vaultSettings.usesReadOnlyMode()).thenReturn(new SimpleBooleanProperty(true));
Mockito.when(vaultSettings.displayName()).thenReturn(new SimpleStringProperty("Vault"));
System.setProperty("user.home", tmpDir.toString());