Skip to content

Commit

Permalink
Merge pull request quarkusio#36799 from cescoffier/fix-32092
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier authored Nov 3, 2023
2 parents 72d993c + efd5a54 commit d4c91a3
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,25 @@ private void doObserve(Collection<Watcher> watchers, long intervalMs) {
for (Watcher watcher : watchers) {
try {
Path rootPath = watcher.rootPath;
List<Path> matchingPaths = Files.walk(rootPath)
.filter(path -> hasExtension(path, watcher.fileExtension))
.collect(Collectors.toList());
List<Path> changedFiles = new ArrayList<>();
for (Path path : matchingPaths) {
long lastModifiedTime = Files.getLastModifiedTime(path).toMillis();
if (lastModifiedTime > lastModified.computeIfAbsent(path, whatever -> 0L)) {
changedFiles.add(path);
lastModified.put(path, lastModifiedTime);
}
if (!rootPath.toFile().isDirectory()) {
// Skip directory - it does not exist.
continue;
}

if (!firstRun && !changedFiles.isEmpty()) {
watcher.action.accept(changedFiles);
try (var walker = Files.walk(rootPath)) {
List<Path> matchingPaths = walker.filter(path -> hasExtension(path, watcher.fileExtension))
.collect(Collectors.toList());
List<Path> changedFiles = new ArrayList<>();
for (Path path : matchingPaths) {
long lastModifiedTime = Files.getLastModifiedTime(path).toMillis();
if (lastModifiedTime > lastModified.computeIfAbsent(path, whatever -> 0L)) {
changedFiles.add(path);
lastModified.put(path, lastModifiedTime);
}
}
if (!firstRun && !changedFiles.isEmpty()) {
watcher.action.accept(changedFiles);
}
}
} catch (IOException e) {
log.debug("Failed checking for code gen source modifications", e);
Expand Down

0 comments on commit d4c91a3

Please sign in to comment.