gmethvin / directory-watcher

A cross-platform Java recursive directory watcher, with a JNA macOS watcher and Scala better-files integration
Apache License 2.0
265 stars 34 forks source link

Multi copy fix #39

Closed mangum99 closed 5 years ago

mangum99 commented 5 years ago

possible fix for #37 & #35

mangum99 commented 5 years ago

@gmethvin basically I've added the check on ENTRY_DELETE when directory then all pathHashes starting with this path should be deleted. I've run also tests on my Win-Computer and they were green. From here I'd need some assistence and maybe some suggestion - instead of using future.get() and waiting for 5 sec, we could use awaitlity with some timeout? (that should make tests run a little faster)

gmethvin commented 5 years ago

Thanks. This looks like the right approach.

I would suggest adding a different test case for what you're trying to test, rather than modifying an existing test case. This way it's easy to see that the previous test still passes.

If you check https://ci.appveyor.com/project/gmethvin/directory-watcher/builds/22961252, you see messages like this:

DEBUG io.methvin.watcher.DirectoryWatcher - Failed to hash created file [C:\Users\appveyor\AppData\Local\Temp\1\4625184721898994304\parent-646139223358167817\child-1012901355892023436.dat]. It may have been deleted.

It's possible in the CI environment it just takes longer for those events to get emitted, so the test ends up finishing before the watcher detects them. You could try adding a longer delay, and maybe also a short delay between the copySubDirectoryFromOutside tests. I wouldn't be opposed to a utility like Awaitility if you wanted to try it.

Also, somehow the code formatting has changed on many files. If you run sbt compile test:compile it will automatically format them properly.