http://www.perlmonks.org?node_id=774579


in reply to Race condition in Linux::Inotify2 between dir and new file?

Wouldn't you be better off using the IN_CLOSE_WRITE and IN_MOVED_TO events?

IN_CREATE sounds to me like it fires when the file gets created, i.e. at open time, while it seems you're more interested in knowing when the file contents are fully there.

IN_CLOSE_WRITE sounds like it would take care of this for you for new files that get created in the watched directory (which I assume also covers a copy), while IN_MOVED_TO would take care of existing files that get added to the directory (either through move or link)

(Big disclaimer: I haven't used inotify myself, I'm just speculating based on gut instinct and the docs)