Skip to content

Commit ce1eabe

Browse files
committed
🚑 Fix directory watching
1 parent b72b8bc commit ce1eabe

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

modules/script-deployer/src/main/java/com/slemarchand/script/deployer/internal/DirectoryWatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void start() {
3636
@Override
3737
public void run() {
3838
try (WatchService watcher = FileSystems.getDefault().newWatchService()) {
39-
Path path = _directory.toPath().getParent();
39+
Path path = _directory.toPath();
4040
path.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY);
4141
while (!isStopped()) {
4242
WatchKey key;
@@ -56,7 +56,7 @@ public void run() {
5656
continue;
5757
} else if (kind == java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY
5858
|| kind == java.nio.file.StandardWatchEventKinds.ENTRY_CREATE) {
59-
doOnChange(filename.toFile());
59+
doOnChange(new File(_directory, filename.toString()));
6060
}
6161
boolean valid = key.reset();
6262
if (!valid) { break; }

modules/script-deployer/src/main/java/com/slemarchand/script/deployer/internal/ScriptDeployer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void activate() {
4848
}
4949
}
5050

51-
_fileWatcher = new DirectoryWatcher(autoDeployDir) {
51+
_directoryWatcher = new DirectoryWatcher(autoDeployDir) {
5252

5353
@Override
5454
public void doOnChange(File file) {
@@ -60,7 +60,7 @@ public void doOnChange(File file) {
6060
}
6161
};
6262

63-
_fileWatcher.start();
63+
_directoryWatcher.start();
6464
}
6565
}
6666

@@ -69,8 +69,8 @@ public void deactivate() {
6969

7070
_log.debug("deactivate()");
7171

72-
if(_fileWatcher != null) {
73-
_fileWatcher.stopThread();
72+
if(_directoryWatcher != null) {
73+
_directoryWatcher.stopThread();
7474
}
7575
}
7676

@@ -141,7 +141,7 @@ private String _getScriptLanguage(File file) {
141141
@Reference
142142
private Scripting _scripting;
143143

144-
private DirectoryWatcher _fileWatcher;
144+
private DirectoryWatcher _directoryWatcher;
145145

146146
private final static Map<String, String> _EXTENSION_LANGUAGE_MAP;
147147

0 commit comments

Comments
 (0)