tags:

views:

40

answers:

2

Hello!

My FTP client (apache commons ftpclient) needs to download file from FTP.

The problem is that an external service may not have finished writing to this file before I start downloading.

Is there any way to determine via FTP whether the file is already closed (i.e. there is no writing handlers opened)?

The problem is that I cannot synchronize with that external service. But I mustn't download file which is not finished yet (a large JPEG).

Thanks in advance!

+1  A: 

You cannot check if the file is closed via vanilla FTP protocol - there's just nothing of the sort in it.

If you can, you could instruct the external service to generate files in some sort of a temp directory and then move it over into the FTP directory. As long as both the temporary and FTP dir are on the same partition (on Linux, no idea about Windows) the move should be instantaneous.

ivans
Unfortunately I cannot communicate with that external service at all.
Andrey
You then seem to be in a world of hurt :-(
ivans
A: 

Copied from myself.

Just download the file. If it is a large file then after the download completes wait as long as is reasonable for your scenario and continue the download from the point it stopped. Repeat until there is no more stuff to download.

Igal Serban