FIX: FTP - download progress, close target file at error

This commit is contained in:
Alexander Koblov 2020-05-26 13:59:23 +00:00
commit 1f7d3e0067
2 changed files with 4 additions and 4 deletions

View file

@ -648,7 +648,7 @@ begin
begin
FLastError:= libssh2_session_last_errno(FSession);
if (FLastError <> LIBSSH2_ERROR_EAGAIN) then Exit(False);
if (FileSize > 0) then DoProgress((FileSize - TotalBytesToRead) * 100 div FileSize);
if (FileSize > 0) then DoProgress(TotalBytesToRead * 100 div FileSize);
FSock.CanRead(10);
end;
until not ((SourceHandle = nil) and (FLastError = LIBSSH2_ERROR_EAGAIN));
@ -680,11 +680,11 @@ begin
end;
Result:= True;
finally
RetrStream.Free;
FreeMem(FBuffer);
Result:= CloseChannel(SourceHandle) and Result;
end;
finally
RetrStream.Free;
libssh2_session_set_blocking(FSession, 1);
end;
end;

View file

@ -323,7 +323,7 @@ begin
begin
FLastError:= libssh2_session_last_errno(FSession);
if (FLastError <> LIBSSH2_ERROR_EAGAIN) then Exit(False);
if (FileSize > 0) then DoProgress((FileSize - TotalBytesToRead) * 100 div FileSize);
if (FileSize > 0) then DoProgress(TotalBytesToRead * 100 div FileSize);
FSock.CanRead(10);
end;
until not ((SourceHandle = nil) and (FLastError = LIBSSH2_ERROR_EAGAIN));
@ -355,11 +355,11 @@ begin
end;
Result:= True;
finally
RetrStream.Free;
FreeMem(FBuffer);
Result:= FileClose(SourceHandle) and Result;
end;
finally
RetrStream.Free;
libssh2_session_set_blocking(FSession, 1);
end;
end;