fixing bug where the mountName of the vault is initially set as the default one

This commit is contained in:
Armin Schrenk
2020-07-17 11:57:53 +02:00
parent d3063c8117
commit 7e0ffb43a6
@@ -63,12 +63,18 @@ public class VaultSettings {
return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, revealAfterMount, useCustomMountPath, customMountPath, usesReadOnlyMode, mountFlags, filenameLengthLimit, actionAfterUnlock};
}
private void deriveMountNameFromPathOrUseDefault(Path path) {
if (StringUtils.isBlank(mountName.get())) {
if (path != null && path.getFileName() != null) {
mountName.set(normalizeMountName(path.getFileName().toString()));
} else {
mountName.set(DEFAULT_MOUNT_NAME);
private void deriveMountNameFromPathOrUseDefault(Path newPath) {
final boolean mountNameSet = !StringUtils.isBlank(mountName.get());
final boolean dirnameExists = (newPath != null) && (newPath.getFileName() != null);
if (!mountNameSet && dirnameExists) {
mountName.set(normalizeMountName(newPath.getFileName().toString()));
} else if (!mountNameSet && !dirnameExists) {
mountName.set(DEFAULT_MOUNT_NAME+id);
}else if (mountNameSet && dirnameExists) {
if(mountName.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());
}
}
}