Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No progress when uploading througth SFTP #19

Open
mebo opened this issue Mar 1, 2021 · 4 comments
Open

No progress when uploading througth SFTP #19

mebo opened this issue Mar 1, 2021 · 4 comments

Comments

@mebo
Copy link

mebo commented Mar 1, 2021

The progress information during download (OnProgress event) is driven due to

if Assigned(TGPSFTP.OnProgress) then
 TGPSFTP.OnProgress(Offset+bufsize,false);

In write_to_stream(), is there a reason the same code is not in read_from_stream() to give equal progress during upload?
Like this:

function read_from_stream(const offset:UInt64;const buffer:Pointer;const bufsize:Integer;const libctx:PTGLibraryContext):Integer; cdecl;
var TGPSFTP:TTGPuttySFTP;
begin
  TGPSFTP:=TTGPuttySFTP(libctx.Tag);
  if Assigned(TGPSFTP.FUploadStream) then begin
     TGPSFTP.FUploadStream.Position:=Offset;
     Result:=TGPSFTP.FUploadStream.Read(buffer^,bufsize);
     if Assigned(TGPSFTP.OnProgress) then
        TGPSFTP.OnProgress(Offset+bufsize,false);
     end
  else
     Result:=0;
  end;
@superflexible
Copy link
Owner

Hello,
for uploads, the progress is called from within the DLL, so it's not needed here. Progress callback is only triggered after 1 MB of transfer and at least 1 second time. This is to make sure the transfer rate can be maxed out. If you add the callback to read_from_stream, it will slow it down.

@mebo
Copy link
Author

mebo commented Mar 2, 2021

Hi,

I see what you mean (I now understand why I didn't get any progress through progress_callback() (I was testing with too small files).

However, I also get these kinds of updates when downloading, so is there a reason 'extra' progress is provided when downloading by write_to_stream(), but not in read_from_stream()? Why is there a different approach between the two?

@superflexible
Copy link
Owner

Hello,
actually I don't know, it might be redundant in write_to_stream because the DLL itself calls the progress callback too. I will investigate this in the future. Maybe you can try what happens if you remove the progress call from write_to_stream. Or maybe the call from the DLL just doesn't work and therefore it was added on the Pascal side.

@mebo
Copy link
Author

mebo commented Mar 2, 2021

Hello,
actually I don't know, it might be redundant in write_to_stream because the DLL itself calls the progress callback too. I will investigate this in the future. Maybe you can try what happens if you remove the progress call from write_to_stream. Or maybe the call from the DLL just doesn't work and therefore it was added on the Pascal side.

I've checked by removing the calls from write_to_stream(), in that case it behaves exactly the same as uploading does, so I get a progress callback about once a second.

I'd suggest to remove the extra calls from write_to_stream(), also because there is a bool you can return to abort the transfer, but that obviously only will work when the OnProgress event came from progress_callback() and not when it came from write_to_stream()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants