From bc06cc1b29dabbfa05cbca837d23076a82302cb7 Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Wed, 8 Mar 2023 15:56:12 +0100 Subject: [PATCH 1/2] Not creating config dir if non existing Signed-off-by: Florian Dupuy --- .../java/com/powsybl/commons/config/PlatformConfig.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/commons/src/main/java/com/powsybl/commons/config/PlatformConfig.java b/commons/src/main/java/com/powsybl/commons/config/PlatformConfig.java index e65ba96ca85..d40a3503378 100644 --- a/commons/src/main/java/com/powsybl/commons/config/PlatformConfig.java +++ b/commons/src/main/java/com/powsybl/commons/config/PlatformConfig.java @@ -10,13 +10,14 @@ import com.google.common.base.Suppliers; import com.google.common.collect.Lists; import com.powsybl.commons.PowsyblException; -import com.powsybl.commons.io.FileUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; import java.util.ServiceLoader; /** @@ -87,7 +88,7 @@ public PlatformConfig(ModuleConfigRepository repository, Path configDir) { protected PlatformConfig(Supplier repositorySupplier, Path configDir) { this.repositorySupplier = Suppliers.memoize(Objects.requireNonNull(repositorySupplier)); - this.configDir = configDir != null ? FileUtil.createDirectory(configDir) : null; + this.configDir = configDir; } public Optional getConfigDir() { From ca8dd44afa4735bd705be46b4c317efefbfd85e6 Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Wed, 8 Mar 2023 15:56:41 +0100 Subject: [PATCH 2/2] Creating config dir in InMemoryPlatformConfig Signed-off-by: Florian Dupuy --- .../com/powsybl/commons/config/InMemoryPlatformConfig.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commons/src/main/java/com/powsybl/commons/config/InMemoryPlatformConfig.java b/commons/src/main/java/com/powsybl/commons/config/InMemoryPlatformConfig.java index e5cfb676bff..ecaeeda6696 100644 --- a/commons/src/main/java/com/powsybl/commons/config/InMemoryPlatformConfig.java +++ b/commons/src/main/java/com/powsybl/commons/config/InMemoryPlatformConfig.java @@ -6,6 +6,8 @@ */ package com.powsybl.commons.config; +import com.powsybl.commons.io.FileUtil; + import java.nio.file.FileSystem; /** @@ -15,7 +17,8 @@ public class InMemoryPlatformConfig extends PlatformConfig { public InMemoryPlatformConfig(FileSystem fileSystem) { - super(new InMemoryModuleConfigRepository(fileSystem), fileSystem.getPath("inmemory").toAbsolutePath()); + super(new InMemoryModuleConfigRepository(fileSystem), + FileUtil.createDirectory(fileSystem.getPath("inmemory").toAbsolutePath())); } public MapModuleConfig createModuleConfig(String name) {