FTP Get resume

Giganews Newsgroups
Subject: FTP Get resume
Posted by:  Bill Thomasson (bthomass…@custard.com)
Date: Wed, 26 Jul 2006

I am having trouble with resuming gets

I have the line:

  IdFTP.Get(sRemoteFileName, sLocalFile,False,True);

But watching the file transfer, if it the connection was broken previously, it starts again at
0 bytes.

Looking into the idFTP.pas, the Get Creates the append stream, and then calls Get with the
stream.

procedure TIdFTP.Get(const ASourceFile: string; ADest: TIdStream; AResume: Boolean = False);
begin
  //for SSL FXP, we have to do it here because InternalGet is used by the LIST command
  //where SSCN is ignored.
  ClearSSCN;
  AResume := AResume and CanResume;
  ADest.Position := 0; <-------------- Starts from begining. Bill
  InternalGet('RETR ' + ASourceFile, ADest, AResume);
end;

It then sets the destination to the begining of the stream, overwriting what was there.
If I comment out ADest.Position := 0; then it picks up where it left off.

Is this a bug?  Is there some other reason that in a resume it should be setting the position to 0?

Possibly it should be

if Not AResume Then
  ADest.Position := 0;

Thanks for any input, just don't want to change Indy code without confirmation.  In all my testing
it seams to fix the problem and allow resumes to work.

Bill Thomasson

Replies