This commit is contained in:
Sebastian Stenzel 2015-03-12 19:10:43 +01:00
parent 05abea0508
commit c10d80de18

View File

@ -137,18 +137,21 @@ public class MainController implements Initializable, InitializationListener, Un
final FileChooser fileChooser = new FileChooser();
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Cryptomator vault", "*" + Vault.VAULT_FILE_EXTENSION));
final File file = fileChooser.showSaveDialog(stage);
if (file == null) {
return;
}
try {
if (file != null) {
final Path vaultDir;
// enforce .cryptomator file extension:
if (!file.getName().endsWith(Vault.VAULT_FILE_EXTENSION)) {
final Path correctedPath = file.toPath().resolveSibling(file.getName() + Vault.VAULT_FILE_EXTENSION);
vaultDir = Files.createDirectory(correctedPath);
vaultDir = file.toPath().resolveSibling(file.getName() + Vault.VAULT_FILE_EXTENSION);
} else {
vaultDir = Files.createDirectory(file.toPath());
vaultDir = file.toPath();
}
if (!Files.exists(vaultDir)) {
Files.createDirectory(vaultDir);
}
addVault(vaultDir, true);
}
} catch (IOException e) {
LOG.error("Unable to create vault", e);
}