mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-14 08:41:28 +00:00
fixes automount on linux distributions, that do not accept the [::1] literal as localhost
fixes reset of Settings, if a Vault no longer exists upon Cryptomator startup
This commit is contained in:
@@ -47,9 +47,6 @@ public class Vault implements Serializable {
|
||||
* Package private constructor, use {@link VaultFactory}.
|
||||
*/
|
||||
Vault(final Path vaultDirectoryPath, final WebDavServer server, final Cryptor cryptor, final WebDavMounter mounter, final DeferredCloser closer) {
|
||||
if (!Files.isDirectory(vaultDirectoryPath) || !vaultDirectoryPath.getFileName().toString().endsWith(VAULT_FILE_EXTENSION)) {
|
||||
throw new IllegalArgumentException("Not a valid vault directory: " + vaultDirectoryPath);
|
||||
}
|
||||
this.path = vaultDirectoryPath;
|
||||
this.server = server;
|
||||
this.cryptor = cryptor;
|
||||
@@ -63,6 +60,10 @@ public class Vault implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidVaultDirectory() {
|
||||
return Files.isDirectory(path) && path.getFileName().toString().endsWith(VAULT_FILE_EXTENSION);
|
||||
}
|
||||
|
||||
public boolean containsMasterKey() throws IOException {
|
||||
final Path masterKeyPath = path.resolve(VAULT_MASTERKEY_FILE);
|
||||
return Files.isRegularFile(masterKeyPath);
|
||||
|
||||
@@ -59,6 +59,7 @@ public class SettingsProvider implements Provider<Settings> {
|
||||
final Path settingsFile = SETTINGS_DIR.resolve(SETTINGS_FILE);
|
||||
final InputStream in = Files.newInputStream(settingsFile, StandardOpenOption.READ);
|
||||
settings = objectMapper.readValue(in, Settings.class);
|
||||
settings.getDirectories().removeIf(v -> !v.isValidVaultDirectory());
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Failed to load settings, creating new one.");
|
||||
settings = new Settings();
|
||||
|
||||
@@ -40,13 +40,15 @@ final class LinuxGvfsWebDavMounter implements WebDavMounterStrategy {
|
||||
public WebDavMount mount(URI uri, String name) throws CommandFailedException {
|
||||
final Script mountScript = Script.fromLines(
|
||||
"set -x",
|
||||
"gvfs-mount \"dav:$DAV_SSP\"",
|
||||
"xdg-open \"dav:$DAV_SSP\"")
|
||||
.addEnv("DAV_SSP", uri.getRawSchemeSpecificPart());
|
||||
"gvfs-mount \"dav://localhost:$DAV_PORT$DAV_PATH\"",
|
||||
"xdg-open \"dav://localhost:$DAV_PORT$DAV_PATH\"")
|
||||
.addEnv("DAV_PORT", String.valueOf(uri.getPort()))
|
||||
.addEnv("DAV_PATH", uri.getRawPath());
|
||||
final Script unmountScript = Script.fromLines(
|
||||
"set -x",
|
||||
"gvfs-mount -u \"dav:$DAV_SSP\"")
|
||||
.addEnv("$DAV_SSP", uri.getRawSchemeSpecificPart());
|
||||
"gvfs-mount -u \"dav://localhost:$DAV_PORT$DAV_PATH\"")
|
||||
.addEnv("DAV_PORT", String.valueOf(uri.getPort()))
|
||||
.addEnv("DAV_PATH", uri.getRawPath());
|
||||
mountScript.execute();
|
||||
return new WebDavMount() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user