Fix crash, if config dir does not exist
This commit is contained in:
parent
625e972853
commit
76467cb346
|
@ -90,6 +90,10 @@ public class Config {
|
||||||
} else {
|
} else {
|
||||||
src = new File(configDirectory, previousVersion.toString());
|
src = new File(configDirectory, previousVersion.toString());
|
||||||
}
|
}
|
||||||
|
if (!src.exists()) {
|
||||||
|
// new installation
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!Objects.equals(previousVersion, currentVersion)) {
|
if (!Objects.equals(previousVersion, currentVersion)) {
|
||||||
LOG.debug("Version update {} -> {}", previousVersion, currentVersion);
|
LOG.debug("Version update {} -> {}", previousVersion, currentVersion);
|
||||||
LOG.debug("Copying config from {} to {}", src, target);
|
LOG.debug("Copying config from {} to {}", src, target);
|
||||||
|
@ -98,11 +102,16 @@ public class Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Version getPreviousVersion(File configDirectory) {
|
private Version getPreviousVersion(File configDirectory) {
|
||||||
Optional<Version> previousVersion = Arrays.stream(configDirectory.listFiles((dir, name) -> name.matches("\\d+\\.\\d+\\.\\d+")))
|
File[] versionDirectories = configDirectory.listFiles((dir, name) -> name.matches("\\d+\\.\\d+\\.\\d+"));
|
||||||
|
if (versionDirectories != null) {
|
||||||
|
Optional<Version> previousVersion = Arrays.stream(versionDirectories)
|
||||||
.map(File::getName)
|
.map(File::getName)
|
||||||
.map(Version::of)
|
.map(Version::of)
|
||||||
.max(Comparator.naturalOrder());
|
.max(Comparator.naturalOrder());
|
||||||
return previousVersion.orElse(Version.of("4.7.5"));
|
return previousVersion.orElse(Version.of("4.7.5"));
|
||||||
|
} else {
|
||||||
|
return Version.of("4.7.5");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load() throws IOException {
|
private void load() throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue