commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "François SENEQUIER" <aeptec...@gmail.com>
Subject [FTP incomplete file transfer]
Date Fri, 25 May 2007 15:51:19 GMT
Hi,

I use a FTPClient for downloading a file existing in a directory of a FTP
server (retrieveFileStream).

In fact, I suppose it is a classical FTP problem but following the
configuration of the FTP server, the beginning of a downloading file is
possible even if the uploaded file is incomplete (always uploading). For
instance, with FileZilla Server it is possible to unvalidate a check box
"Allow downloading of file which are open for writing by another process -
Please notice that this can result in corrupt transfers".

If I try to download a file which is again uploading, the downloaded file is
incomplete.

But I would try to know how detecting that a file is on the FTP server is
uploading. In this case either I don't want to start the download or I wait
for the end of the upload.

So I try to rename the file (with FTPClient.rename) to his own name. So if
it is possible to rename the file it is that the file is not locked by the
upload, so the upload has ended. This method is okay for some servers but
not all. FileZilla server refuses to rename a file to his own name even if
there is no lock.

So I would prefer trying to put a lock on the file before trying to download
the file. So if the file is uploading, the lock will fail. The file is not
uploading, the lock will success. But to put a lock on the file, I have to
use the method getChannel().tryLock() from a File, or FileInputStream. But I
just have an "InputStream" with the "FTPClient" method. How to put a lock on
the InputStream ?

Or have you got another way to solve the problem ?

Thanks

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message