Skip to content

Commit b932a4d

Browse files
authored
YAML files: ignore files inside automation sub-folder (#4291)
Also ignore unreachable files Signed-off-by: Laurent Garnier <[email protected]>
1 parent 2be44d1 commit b932a4d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/YamlModelRepositoryImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ public YamlModelRepositoryImpl(@Reference(target = WatchService.CONFIG_WATCHER_F
9999

100100
// read initial contents
101101
try (Stream<Path> files = Files.walk(watchPath)) {
102-
files.filter(Files::isRegularFile).map(watchPath::relativize).forEach(f -> processWatchEvent(CREATE, f));
102+
files.filter(f -> Files.isReadable(f) && Files.isRegularFile(f)).map(watchPath::relativize)
103+
.forEach(f -> processWatchEvent(CREATE, f));
103104
} catch (IOException e) {
104105
logger.warn("Could not list YAML files in '{}', models might be missing: {}", watchPath, e.getMessage());
105106
}
@@ -116,7 +117,8 @@ public void deactivate() {
116117
public synchronized void processWatchEvent(Kind kind, Path path) {
117118
Path fullPath = watchPath.resolve(path);
118119
String pathString = path.toString();
119-
if (Files.isDirectory(fullPath) || fullPath.toFile().isHidden() || !pathString.endsWith(".yaml")) {
120+
if (!Files.isReadable(fullPath) || Files.isDirectory(fullPath) || path.startsWith("automation")
121+
|| !pathString.endsWith(".yaml") || fullPath.toFile().isHidden()) {
120122
logger.trace("Ignored {}", fullPath);
121123
return;
122124
}

0 commit comments

Comments
 (0)