From 681308d1a1327f3458c42024271dc0e5adffb241 Mon Sep 17 00:00:00 2001 From: "Jan N. Klug" Date: Sun, 10 Nov 2024 13:39:25 +0100 Subject: [PATCH] Improve FolderObserver It has been reported that missing model directories cause issued during startup. With this PR a directory is created when it is missing. Signed-off-by: Jan N. Klug --- .../core/model/core/internal/folder/FolderObserver.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java index ff26c8f1ff0..c18045f1600 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java @@ -96,6 +96,14 @@ protected void addModelParser(ModelParser modelParser) { logger.debug("Adding parser for '{}' extension", extension); parsers.add(extension); + // check if the desired directory exists and create it if it's missing + try { + Path extensionPath = watchService.getWatchPath().resolve(extension); + Files.createDirectories(extensionPath); + } catch (IOException e) { + logger.error("Model path for extension '{}' is missing and creation failed: {}", extension, e.getMessage()); + } + if (activated) { processIgnoredPaths(extension); readyService.markReady(new ReadyMarker(READYMARKER_TYPE, extension));