Search code examples
file-copyingjnotify

jnotify fires event before file is fully created/copied


i am using jnotify to get an event when a new file is created/copied in a certain directory. When the file is copied in the direcotry, I want to execute a tool with this file as parameter. Problem is: When the file size is large and not instantly copied in the directory, i can't start the tool with this file, because it's still copying this file.

Any suggesstions to solve this problem? Is there a way to check if a file is "ready"?


Solution

  • JNotify is hooking to the file system events, and you get what is reported by the OS. what you can do is to use a timer to wait for a second or two of inactivity for that file before activating your action.