Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: IdFTP.Get Not Firing OnAfterGet

www.cryer.info
Managed Newsgroup Archive

Re: IdFTP.Get Not Firing OnAfterGet

Subject:Re: IdFTP.Get Not Firing OnAfterGet
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Wed, 14 Mar 2007 10:51:40

"Richard Stephens" <rick@almsysinc.com> wrote in message
news:45f81ea2$1@newsgroups.borland.com...

> I am using the syntax: IdFTP1.Get(WebFileName,LocalFileName,True);
>
> It DOES download the file and give it the correct LocalFileName,
> but the IdFTP1.OnAfterGet logic does not fire.

Yes, it does.   That is a guarantee.  Get(String, String, Boolean,
Boolean) calls Get(String, Stream, Boolean) internally.  That second
Get() is what does all of the work, and always triggers the OnAfterGet
event handler if successful.  It is not possible for the OnAfterGet
handler to be ignored on a successful transfer if it is assigned.

> I am using OnAfterGet to tell me that it was successful

Indy is not an event-driven library.  If Get() does not raise an
exception, then the transfer was successful.  You don't need an event
to tell you that.

> Rather, it simply returns control to the next statement after
> the Get command. It does not get an exception.

That is physically impossible, as DoAfterGet() is the last call in
Get(String, Stream, Boolean) if an exception is not thrown.  It can't
be bypassed (unless the call stack is getting corrupted).

> If I change the syntax to
IdFTP1.Get(WebFileName,LocalFileName,True,True);
> and test it, it gives me an EIdFTPFileAlreadyExists exception ....
but the
> LocalFileName does not exist.

Yes, it does.  That exception is only raised if FileExists() returned
True.

> And if it did, it should have overwritten it.

No, it shouldn't have.  You set both ACanOverwrite and AResume to
True.  The file cannot be overwritten during a resumed transfer.  You
have to set ACanOverwrite to False in order for resuming to work.
Otherwise set ACanOverwrite to True and AResume to False to start the
file from the beginning always, even if it already exits.

> I am assuming this is yet another difference between Indy 9 and 10
> that I am running into.....

No.  Indy 9 worked the same way as I have described.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive