|
28 | 28 | import java.nio.file.attribute.BasicFileAttributes; |
29 | 29 | import java.nio.file.attribute.FileTime; |
30 | 30 | import java.util.HashMap; |
31 | | -import java.util.HashSet; |
32 | 31 | import java.util.List; |
33 | 32 | import java.util.Map; |
34 | 33 | import java.util.Set; |
35 | 34 | import java.util.concurrent.ExecutionException; |
| 35 | +import java.util.stream.Collectors; |
36 | 36 | import java.util.stream.Stream; |
37 | 37 |
|
38 | 38 | /** |
@@ -238,16 +238,16 @@ protected final void watcherThread() { |
238 | 238 | key.reset(); |
239 | 239 |
|
240 | 240 | if (key == settingsDirWatchKey) { |
241 | | - // there may be multiple events for the same file - we only want to re-read once |
242 | | - Set<Path> processedFiles = new HashSet<>(); |
243 | | - for (WatchEvent<?> e : events) { |
244 | | - Path fullFile = settingsDir.resolve(e.context().toString()); |
245 | | - if (Files.isSymbolicLink(fullFile)) { |
| 241 | + Set<Path> changedPaths = events.stream() |
| 242 | + .map(event -> settingsDir.resolve(event.context().toString())) |
| 243 | + .collect(Collectors.toSet()); |
| 244 | + for (var changedPath : changedPaths) { |
| 245 | + // If a symlink changed in the settings directory, it could be linked to other symlinks so reprocess all files |
| 246 | + if (Files.isSymbolicLink(changedPath)) { |
246 | 247 | reprocessAllChangedFilesInSettingsDir(); |
247 | | - } else if (processedFiles.add(fullFile)) { |
248 | | - if (fileChanged(fullFile)) { |
249 | | - process(fullFile); |
250 | | - } |
| 248 | + break; |
| 249 | + } else if (fileChanged(changedPath)) { |
| 250 | + process(changedPath); |
251 | 251 | } |
252 | 252 | } |
253 | 253 | } else if (key == configDirWatchKey) { |
|
0 commit comments