Skip to content

Commit

Permalink
Fix transformations not removed if file deleted
Browse files Browse the repository at this point in the history
Signed-off-by: Jan N. Klug <github@klug.nrw>
  • Loading branch information
J-N-K committed May 1, 2022
1 parent 4ab0f83 commit c708bbb
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,14 @@ protected void processWatchEvent(WatchEvent<?> event, WatchEvent.Kind<?> kind, P
}

private void processPath(WatchEvent.Kind<?> kind, Path path) {
if (!Files.isRegularFile(path)) {
logger.trace("Skipping {} event for '{}' - not a regular file", kind, path);
return;
}
if (StandardWatchEventKinds.ENTRY_DELETE.equals(kind)) {
TransformationConfiguration oldElement = transformationConfigurations.remove(path);
if (oldElement != null) {
logger.trace("Removed configuration from file '{}", path);
listeners.forEach(listener -> listener.removed(this, oldElement));
}
} else if (StandardWatchEventKinds.ENTRY_CREATE.equals(kind)
|| StandardWatchEventKinds.ENTRY_MODIFY.equals(kind)) {
} else if (Files.isRegularFile(path) && (StandardWatchEventKinds.ENTRY_CREATE.equals(kind)
|| StandardWatchEventKinds.ENTRY_MODIFY.equals(kind))) {
try {
String fileName = path.getFileName().toString();
Matcher m = FILENAME_PATTERN.matcher(fileName);
Expand Down Expand Up @@ -151,6 +147,8 @@ private void processPath(WatchEvent.Kind<?> kind, Path path) {
} catch (IOException e) {
logger.warn("Skipping {} event for '{}' - failed to read content: {}", kind, path, e.getMessage());
}
} else {
logger.trace("Skipping {} event for '{}' - not a regular file", kind, path);
}
}
}

0 comments on commit c708bbb

Please sign in to comment.