Be more lenient when handling open vault events

either via drag and drop or registered file extensions
This commit is contained in:
Sebastian Stenzel
2021-09-24 10:57:05 +02:00
parent d07c018670
commit 79c48778ce
3 changed files with 8 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ public interface Constants {
String MASTERKEY_FILENAME = "masterkey.cryptomator";
String MASTERKEY_BACKUP_SUFFIX = ".bkup";
String VAULTCONFIG_FILENAME = "vault.cryptomator";
String CRYPTOMATOR_FILENAME_EXT = ".cryptomator";
byte[] PEPPER = new byte[0];
}

View File

@@ -11,12 +11,11 @@ import javax.inject.Named;
import javax.inject.Singleton;
import javafx.application.Platform;
import java.io.IOException;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import static org.cryptomator.common.Constants.MASTERKEY_FILENAME;
import static org.cryptomator.common.Constants.CRYPTOMATOR_FILENAME_EXT;
@Singleton
class AppLaunchEventHandler {
@@ -69,7 +68,7 @@ class AppLaunchEventHandler {
assert Platform.isFxApplicationThread();
try {
final Vault v;
if (potentialVaultPath.getFileName().toString().equals(MASTERKEY_FILENAME)) {
if (potentialVaultPath.getFileName().toString().endsWith(CRYPTOMATOR_FILENAME_EXT)) {
v = vaultListManager.add(potentialVaultPath.getParent());
} else {
v = vaultListManager.add(potentialVaultPath);

View File

@@ -27,6 +27,7 @@ import java.nio.file.Path;
import java.util.Set;
import java.util.stream.Collectors;
import static org.cryptomator.common.Constants.CRYPTOMATOR_FILENAME_EXT;
import static org.cryptomator.common.Constants.MASTERKEY_FILENAME;
import static org.cryptomator.common.Constants.VAULTCONFIG_FILENAME;
@@ -94,6 +95,9 @@ public class MainWindowController implements FxController {
private boolean containsVault(Path path) {
try {
if (path.getFileName().toString().endsWith(CRYPTOMATOR_FILENAME_EXT)) {
path = path.getParent();
}
return CryptoFileSystemProvider.checkDirStructureForVault(path, VAULTCONFIG_FILENAME, MASTERKEY_FILENAME) != DirStructure.UNRELATED;
} catch (IOException e) {
return false;
@@ -102,7 +106,7 @@ public class MainWindowController implements FxController {
private void addVault(Path pathToVault) {
try {
if (pathToVault.getFileName().toString().equals(VAULTCONFIG_FILENAME)) {
if (pathToVault.getFileName().toString().endsWith(CRYPTOMATOR_FILENAME_EXT)) {
vaultListManager.add(pathToVault.getParent());
} else {
vaultListManager.add(pathToVault);