Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file-processing in AbstractScriptFileWatcher #3369

Merged
merged 2 commits into from
Feb 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ public AbstractScriptFileWatcher(final WatchService watchService, final ScriptEn
}
}

/**
* Get the base path that is used by this {@link ScriptFileWatcher}
*
* @return the {@link Path} used
*/
protected Path getWatchPath() {
return watchPath;
}

/**
* Can be overridden by subclasses (e.g. for testing)
*
Expand Down Expand Up @@ -212,13 +221,14 @@ private List<Path> listFiles(Path path, boolean includeSubDirectory) {

@Override
public void processWatchEvent(WatchService.Kind kind, Path path) {
File file = path.toFile();
Path fullPath = watchPath.resolve(path);
File file = fullPath.toFile();
if (!file.isHidden()) {
if (kind == DELETE) {
if (file.isDirectory()) {
if (watchSubDirectories) {
synchronized (this) {
String prefix = path.getParent().toString();
String prefix = fullPath.getParent().toString();
Set<String> toRemove = scriptMap.keySet().stream().filter(ref -> ref.startsWith(prefix))
.collect(Collectors.toSet());
toRemove.forEach(this::removeFile);
Expand Down