Skip to content

Commit 634aad3

Browse files
committed
Add extra check to let IndexingRescanner report failures to get last-modified-times only when the files involved truly exist
1 parent 0979b15 commit 634aad3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/engineering/swat/watch/impl/overflows/IndexingRescanner.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,16 @@ public void accept(EventHandlingWatch watch, WatchEvent event) {
179179
watch.handleEvent(watch.relativize(created));
180180
}
181181
} catch (IOException e) {
182-
logger.error("Could not get modification time of: {} ({})", fullPath, e);
182+
// It can happen that, by the time a `CREATED`/`MODIFIED`
183+
// event is handled above, getting the last-modified-time
184+
// fails because the file has already been deleted. That's
185+
// fine: we can just ignore the event. (The corresponding
186+
// `DELETED` event will later be handled and remove the file
187+
// from the index.) If the file exists, though, something
188+
// went legitimately wrong, so it needs to be reported.
189+
if (Files.exists(fullPath)) {
190+
logger.error("Could not get modification time of: {} ({})", fullPath, e);
191+
}
183192
}
184193
break;
185194
case DELETED:

0 commit comments

Comments
 (0)