I think you are solving the wrong problem.
What you have to do is figure out how to say when any FTPd that you use is writing the file - so when you encounter the same problem for (say) GIF, DOC or MPEG, you need to fix it again .
Exactly how you do it, it pretty much depends on which FTPd is running on which OS. Some, I believe, have hooks that you can configure when it boots.
If you can run your own FTPd, Net :: FTPServer or POE :: Component :: Server :: FTP are configured to work properly.
In the absence of this:
1) try closing logs with a Perl script that looks for download completion messages 2) use something like lsof or fuser to check if something is blocking the file before trying to copy it.
source share