views:

58

answers:

1

for large files or slow connections, copying files may take some time.

using pyinotify, i have been watching for the IN_CREATE event code. but this seems to occur at the start of a file transfer. i need to know when a file is completely copied - it aint much use if it's only half there.

when a file transfer is finished and completed, what inotify event is fired?

+1  A: 

IN_CLOSE probably means the write is complete. This isn't for sure since some applications are bad actors and open and close files constantly while working with them, but if you know the app you're dealing with (file transfer, etc.) and understand its' behaviour, you're probably fine. (Note, this doesn't mean the transfer completed successfully, obviously, it just means that the process that opened the file handle closed it).

IN_CLOSE catches both IN_CLOSE_WRITE and IN_CLOSE_NOWRITE, so make your own decisions about whether you want to just catch one of those. (You probably want them both - WRITE/NOWRITE have to do with file permissions and not whether any writes were actually made).

There is more documentation (although annoyingly, not this piece of information) in Documentation/filesystems/inotify.txt.

Nick Bastin
my question pertains specifically to file copying in nautilus. in this case, IN_CLOSE_WRITE is sufficient.IN_CLOSE by itself does not exist in pyinotify.
Jeremiah Rose