ch.vorburger.fswatch icon indicating copy to clipboard operation
ch.vorburger.fswatch copied to clipboard

Replacing a file only creates a delete event not a create event

Open edewit opened this issue 3 years ago • 6 comments

I'm using java.nio.file.Files.move(file1, file2, REPLACE_EXISTING) to replace a file from the watched folder then I only get a DELETED change not a CREATED. I would expect both events to trigger.

edewit avatar Jun 08 '22 08:06 edewit

Interesting. I wonder if that's a bug in this project or the JDK? The former seems more likely.

Do you want to raise a Draft PR with a (failing) test that illustrates this?

vorburger avatar Jun 08 '22 12:06 vorburger

FTR @edewit said that when using com.google.common.io.Files.move(File, File) this problem does not happen. We suspect it's some sort of timing issue. (Once I've figured a solution, perhaps the new test case could cover both.)

vorburger avatar Jun 08 '22 20:06 vorburger

We suspect it's some sort of timing issue.

Perhaps this is related to the ch.vorburger.fswatch.QuietPeriodListener.

vorburger avatar Jun 08 '22 21:06 vorburger

Just tested this and your right it's just a configuration problem with .quietPeriodInMS(0) it works perfectly

edewit avatar Jun 13 '22 05:06 edewit

Let's keep this open? I'm glad it's related to that, and there's a "workaround" (?), but perhaps I could make the quiet filter better aware of different event types, for it to be more "correct".

vorburger avatar Jun 13 '22 05:06 vorburger

I (briefly, mobile, while commuting) looked at src, and that quiet listener doesn't actually seem right to me (in hindsight, I originally wrote it)... I'll see if I can rewrite it, some other evening.

In the meantime, the workaround above (which avoids it from being used) seems like a good solution.

vorburger avatar Jun 13 '22 07:06 vorburger