Accept paths beginning with "~" in cryptomator.settingsPath JVM arg.

[ci skip]
This commit is contained in:
Sebastian Stenzel
2016-08-17 18:52:08 +02:00
parent 1f73a08e09
commit 363ed4ac4b

View File

@@ -65,7 +65,15 @@ public class SettingsProvider implements Provider<Settings> {
private Path getSettingsPath() throws IOException {
final String settingsPathProperty = System.getProperty("cryptomator.settingsPath");
return Optional.ofNullable(settingsPathProperty).filter(StringUtils::isNotBlank).map(FileSystems.getDefault()::getPath).orElse(DEFAULT_SETTINGS_PATH);
return Optional.ofNullable(settingsPathProperty).filter(StringUtils::isNotBlank).map(this::replaceHomeDir).map(FileSystems.getDefault()::getPath).orElse(DEFAULT_SETTINGS_PATH);
}
private String replaceHomeDir(String path) {
if (path.startsWith("~/")) {
return SystemUtils.USER_HOME + path.substring(1);
} else {
return path;
}
}
@Override