I have a service which handles incoming files through FTP.
On my Debian server where Proftpd is installed I use an iNotify event to determine when a file transfer is complete and I can start working with it.
The event is triggered once a file is no longer written to.
This worked perfectly until I discovered that the new Nikon D4 camera and WT-5 wireless transmitter uses the APPE FTP command to send files.
From what I've read it seems the APPE FTP command sends files in data chunks which are appended to the existing file on the server after the first chunk creates the file.
However this result in several iNotify events being triggered as the file is witten to several times instead of once until the connection closes.
Since the files are handled before the file is completed they will result in an error once handled. And I always remove the file once handled.
Since this service of mine must remain fast in handling incoming files I really liked this solution with iNotify and don't really want to timing if the file-size has remained unchanged for n seconds or whatever to determine if the file transfer is complete.
My question is: Is there any way to determine if the file transfer is actually completed without having to check the file-size or comparing the last modified date?
I've tried to find a way to do this in proftpd with no avail.
The xferlog states that the same file was completed several times:
Fri May 11 14:15:41 2012 2 host-95-199-17-243.mobileonline.telia.com 131072 /var/app/incoming/file.JPG b _ i r auser ftp 0 * c
Fri May 11 14:15:43 2012 2 host-95-199-17-243.mobileonline.telia.com 262144 /var/app/incoming/file.JPG b _ i r auser ftp 0 * c
Fri May 11 14:15:47 2012 3 host-95-199-17-243.mobileonline.telia.com 385624 /var/app/incoming/file.JPG b _ i r auser ftp 0 * c
The c at the end means that the transfer was complete.
So if I had to check if the file is actually completed for every incoming file it would mean an unnecessary delay for files which are actually completed.
Seems like this shouldn't be an unusual problem, but cannot find anything about it.
Any ideas?