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 dc6421bff3c..c9354918ae4 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 @@ -75,6 +75,9 @@ public class FolderObserver implements WatchService.WatchEventListener { /* set of file extensions for which we have parsers already registered */ private final Set parsers = new HashSet<>(); + /* set of file extensions for missing parsers during activation */ + private final Set missingParsers = new HashSet<>(); + /* set of files that have been ignored due to a missing parser */ private final Set ignoredPaths = new HashSet<>(); private final Map namePathMap = new HashMap<>(); @@ -135,9 +138,20 @@ public void activate(ComponentContext ctx) { } watchService.registerListener(this, Path.of("")); + addModelsToRepo(); this.activated = true; logger.debug("{} has been activated", FolderObserver.class.getSimpleName()); + + // process ignored paths for missing parsers which were added during activation + for (String extension : missingParsers) { + if (parsers.contains(extension)) { + processIgnoredPaths(extension); + readyService.markReady(new ReadyMarker(READYMARKER_TYPE, extension)); + logger.debug("Marked extension '{}' as ready", extension); + } + } + missingParsers.clear(); } @Deactivate @@ -187,7 +201,7 @@ private void addModelsToRepo() { } for (String extension : validExtensions) { - if (parsers.contains(extension)) { + if (parsers.contains(extension) && !missingParsers.contains(extension)) { readyService.markReady(new ReadyMarker(READYMARKER_TYPE, extension)); logger.debug("Marked extension '{}' as ready", extension); } @@ -243,8 +257,11 @@ private void checkPath(final Path path, final WatchService.Kind kind) { } catch (IOException e) { logger.warn("Error while opening file during update: {}", path.toAbsolutePath()); } - } else { + } else if (extension != null) { ignoredPaths.add(path); + if (!activated) { + missingParsers.add(extension); + } if (logger.isDebugEnabled()) { logger.debug("Missing parser for '{}' extension, added ignored path: {}", extension, path.toAbsolutePath());