Thank you very much,

On Mon, Oct 21, 2013 at 6:27 AM, Dave Roberts <
[email protected]> wrote:

> On 18/10/2013 15:34, Gentian Hila wrote:
> > Documentation says that these events are fired on successful download or
> > upload.
>
> That would appear to be incorrect.
>
> > Is there a way to guarantee that they fire only on success or a some way
> > that I can check within the methods if the download or upload was
> complete?
>
> Currently these callbacks will get called irrespective of whether
> the command was successful.
>
> One way to detect success/failure would be to write your own Ftplet
> implementation without sub-classing DefaultFtplet.  You will then
> need to provide your own implementation of:-
>
> FtpletResult afterCommand(FtpSession session, FtpRequest request,
> FtpReply reply)
>
> Which as you can see, is passed the FtpReply that the STOR/RETR
> commands returned.  You can use that to determine if the transfter
> was successful by looking for a code of
> 'FtpReply.REPLY_226_CLOSING_DATA_CONNECTION', or simply calling the
> isPositive() method.  You would obviously have to check that the
> request is one of the file transfer commands.
>
>
> Another option is via the FtpStatistics methods of setUpload and
> setDownload or the FileObserver notifyUpload/notifyDownload. These
> are only called upon a successful transfer.  The advantage of these
> is that you will be passed information about the file, that the
> Ftplet isn't given.
>
> Unfortunately setting your own implementation currently requires the
> use of internal classes and methods, and this won't be possible if
> you're using an OSGi container.  There is an outstanding ticket and
> fix to remedy this though, if you're not using OSGi or don't mind
> running a patched version of the code (with no guarantee that the
> patch will ever make an official release).
>
>
>

Reply via email to