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

Improve FolderObserver ignored paths handling #3856

Merged
merged 1 commit into from
Oct 21, 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 @@ -75,6 +75,9 @@ public class FolderObserver implements WatchService.WatchEventListener {
/* set of file extensions for which we have parsers already registered */
private final Set<String> parsers = new HashSet<>();

/* set of file extensions for missing parsers during activation */
private final Set<String> missingParsers = new HashSet<>();

/* set of files that have been ignored due to a missing parser */
private final Set<Path> ignoredPaths = new HashSet<>();
private final Map<String, Path> namePathMap = new HashMap<>();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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());
Expand Down