mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 01:26:52 -04:00
change meaning of mount name setting:
* it is now considered the gerenal vault name * methods (except parsing) are renamed accordingly
This commit is contained in:
@@ -42,7 +42,7 @@ public class VaultSettings {
|
||||
|
||||
private final String id;
|
||||
private final ObjectProperty<Path> path = new SimpleObjectProperty();
|
||||
private final StringProperty mountName = new SimpleStringProperty();
|
||||
private final StringProperty displayName = new SimpleStringProperty();
|
||||
private final StringProperty winDriveLetter = new SimpleStringProperty();
|
||||
private final BooleanProperty unlockAfterStartup = new SimpleBooleanProperty(DEFAULT_UNLOCK_AFTER_STARTUP);
|
||||
private final BooleanProperty revealAfterMount = new SimpleBooleanProperty(DEFAULT_REAVEAL_AFTER_MOUNT);
|
||||
@@ -56,25 +56,25 @@ public class VaultSettings {
|
||||
public VaultSettings(String id) {
|
||||
this.id = Objects.requireNonNull(id);
|
||||
|
||||
EasyBind.subscribe(path, this::deriveMountNameFromPathOrUseDefault);
|
||||
EasyBind.subscribe(path, this::deriveDisplayNameFromPathOrUseDefault);
|
||||
}
|
||||
|
||||
Observable[] observables() {
|
||||
return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, revealAfterMount, useCustomMountPath, customMountPath, usesReadOnlyMode, mountFlags, filenameLengthLimit, actionAfterUnlock};
|
||||
return new Observable[]{path, displayName, winDriveLetter, unlockAfterStartup, revealAfterMount, useCustomMountPath, customMountPath, usesReadOnlyMode, mountFlags, filenameLengthLimit, actionAfterUnlock};
|
||||
}
|
||||
|
||||
private void deriveMountNameFromPathOrUseDefault(Path newPath) {
|
||||
final boolean mountNameSet = !StringUtils.isBlank(mountName.get());
|
||||
private void deriveDisplayNameFromPathOrUseDefault(Path newPath) {
|
||||
final boolean mountNameSet = !StringUtils.isBlank(displayName.get());
|
||||
final boolean dirnameExists = (newPath != null) && (newPath.getFileName() != null);
|
||||
|
||||
if (!mountNameSet && dirnameExists) {
|
||||
mountName.set(normalizeMountName(newPath.getFileName().toString()));
|
||||
displayName.set(normalizeMountName(newPath.getFileName().toString()));
|
||||
} else if (!mountNameSet && !dirnameExists) {
|
||||
mountName.set(DEFAULT_MOUNT_NAME + " " + id);
|
||||
displayName.set(DEFAULT_MOUNT_NAME + " " + id);
|
||||
} else if (mountNameSet && dirnameExists) {
|
||||
if (mountName.get().equals(DEFAULT_MOUNT_NAME + id)) {
|
||||
if (displayName.get().equals(DEFAULT_MOUNT_NAME + id)) {
|
||||
//this is okay, since this function is only executed if the path changes (aka, the vault is created or added)
|
||||
mountName.set(newPath.getFileName().toString());
|
||||
displayName.set(newPath.getFileName().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,8 +118,8 @@ public class VaultSettings {
|
||||
return path;
|
||||
}
|
||||
|
||||
public StringProperty mountName() {
|
||||
return mountName;
|
||||
public StringProperty displayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public StringProperty winDriveLetter() {
|
||||
|
||||
@@ -21,7 +21,7 @@ class VaultSettingsJsonAdapter {
|
||||
out.beginObject();
|
||||
out.name("id").value(value.getId());
|
||||
out.name("path").value(value.path().get().toString());
|
||||
out.name("mountName").value(value.mountName().get());
|
||||
out.name("mountName").value(value.displayName().get());
|
||||
out.name("winDriveLetter").value(value.winDriveLetter().get());
|
||||
out.name("unlockAfterStartup").value(value.unlockAfterStartup().get());
|
||||
out.name("revealAfterMount").value(value.revealAfterMount().get());
|
||||
@@ -73,7 +73,7 @@ class VaultSettingsJsonAdapter {
|
||||
in.endObject();
|
||||
|
||||
VaultSettings vaultSettings = (id == null) ? VaultSettings.withRandomId() : new VaultSettings(id);
|
||||
vaultSettings.mountName().set(mountName);
|
||||
vaultSettings.displayName().set(mountName);
|
||||
vaultSettings.path().set(Paths.get(path));
|
||||
vaultSettings.winDriveLetter().set(winDriveLetter);
|
||||
vaultSettings.unlockAfterStartup().set(unlockAfterStartup);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DokanyVolume implements Volume {
|
||||
@Override
|
||||
public void mount(CryptoFileSystem fs, String mountFlags) throws VolumeException, IOException {
|
||||
this.mountPoint = determineMountPoint();
|
||||
String mountName = vaultSettings.mountName().get();
|
||||
String mountName = vaultSettings.displayName().get();
|
||||
try {
|
||||
this.mount = mountFactory.mount(fs.getPath("/"), mountPoint, mountName, FS_TYPE_NAME, mountFlags.strip());
|
||||
} catch (MountFailedException e) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Vault {
|
||||
this.state = state;
|
||||
this.lastKnownException = lastKnownException;
|
||||
this.stats = stats;
|
||||
this.displayableName = Bindings.createStringBinding(this::getDisplayableName, vaultSettings.mountName());
|
||||
this.displayableName = Bindings.createStringBinding(this::getDisplayableName, vaultSettings.displayName());
|
||||
this.displayablePath = Bindings.createStringBinding(this::getDisplayablePath, vaultSettings.path());
|
||||
this.locked = Bindings.createBooleanBinding(this::isLocked, state);
|
||||
this.processing = Bindings.createBooleanBinding(this::isProcessing, state);
|
||||
@@ -230,7 +230,7 @@ public class Vault {
|
||||
}
|
||||
|
||||
public String getDisplayableName() {
|
||||
return vaultSettings.mountName().get();
|
||||
return vaultSettings.displayName().get();
|
||||
}
|
||||
|
||||
public StringBinding accessPointProperty() {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class VaultModule {
|
||||
@DefaultMountFlags
|
||||
public StringBinding provideDefaultMountFlags(Settings settings, VaultSettings vaultSettings) {
|
||||
ObjectProperty<VolumeImpl> preferredVolumeImpl = settings.preferredVolumeImpl();
|
||||
StringProperty mountName = vaultSettings.mountName();
|
||||
StringProperty mountName = vaultSettings.displayName();
|
||||
BooleanProperty readOnly = vaultSettings.usesReadOnlyMode();
|
||||
|
||||
return Bindings.createStringBinding(() -> {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class WebDavVolume implements Volume {
|
||||
if (!server.isRunning()) {
|
||||
server.start();
|
||||
}
|
||||
servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.mountName().get());
|
||||
servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.displayName().get());
|
||||
servlet.start();
|
||||
mount();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SettingsTest {
|
||||
Mockito.verify(changeListener, Mockito.times(2)).accept(settings);
|
||||
|
||||
// third change (to property of list item):
|
||||
vaultSettings.mountName().set("asd");
|
||||
vaultSettings.displayName().set("asd");
|
||||
Mockito.verify(changeListener, Mockito.times(3)).accept(settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class VaultSettingsJsonAdapterTest {
|
||||
VaultSettings vaultSettings = adapter.read(jsonReader);
|
||||
Assertions.assertEquals("foo", vaultSettings.getId());
|
||||
Assertions.assertEquals(Paths.get("/foo/bar"), vaultSettings.path().get());
|
||||
Assertions.assertEquals("test", vaultSettings.mountName().get());
|
||||
Assertions.assertEquals("test", vaultSettings.displayName().get());
|
||||
Assertions.assertEquals("X", vaultSettings.winDriveLetter().get());
|
||||
Assertions.assertEquals("/home/test/crypto", vaultSettings.customMountPath().get());
|
||||
Assertions.assertEquals("--foo --bar", vaultSettings.mountFlags().get());
|
||||
@@ -41,7 +41,7 @@ public class VaultSettingsJsonAdapterTest {
|
||||
public void testSerialize() throws IOException {
|
||||
VaultSettings vaultSettings = new VaultSettings("test");
|
||||
vaultSettings.path().set(Paths.get("/foo/bar"));
|
||||
vaultSettings.mountName().set("mountyMcMountFace");
|
||||
vaultSettings.displayName().set("mountyMcMountFace");
|
||||
vaultSettings.mountFlags().set("--foo --bar");
|
||||
|
||||
StringWriter buf = new StringWriter();
|
||||
|
||||
@@ -28,7 +28,7 @@ public class VaultModuleTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setup(@TempDir Path tmpDir) {
|
||||
Mockito.when(vaultSettings.mountName()).thenReturn(new SimpleStringProperty("TEST"));
|
||||
Mockito.when(vaultSettings.displayName()).thenReturn(new SimpleStringProperty("TEST"));
|
||||
Mockito.when(vaultSettings.usesReadOnlyMode()).thenReturn(new SimpleBooleanProperty(true));
|
||||
System.setProperty("user.home", tmpDir.toString());
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class MountOptionsController implements FxController {
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
driveName.textProperty().bindBidirectional(vault.getVaultSettings().mountName());
|
||||
driveName.textProperty().bindBidirectional(vault.getVaultSettings().displayName());
|
||||
|
||||
// readonly:
|
||||
readOnlyCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().usesReadOnlyMode());
|
||||
|
||||
Reference in New Issue
Block a user