ViktorV wrote:We will consider the possibility to change this behavior of SecureBridge in one of the next releases.
It will be nice
In case of anyone looking for workaround of this problem (in console app):
Code: Select all
...
private
FWorking, FOK: Boolean;
...
function ProcessMessage(var Msg: TMsg): Boolean; // message pump analogue to Vcl.Forms.TApplication
var
Unicode: Boolean;
MsgExists: Boolean;
begin
Result := False;
if PeekMessage(Msg, 0, 0, 0, PM_NOREMOVE) then
begin
Unicode := (Msg.hwnd = 0) or IsWindowUnicode(Msg.hwnd);
if Unicode then
MsgExists := PeekMessageW(Msg, 0, 0, 0, PM_REMOVE)
else
MsgExists := PeekMessageA(Msg, 0, 0, 0, PM_REMOVE);
if MsgExists then
begin
Result := True;
if Msg.Message <> WM_QUIT then
begin
TranslateMessage(Msg);
if Unicode then
DispatchMessageW(Msg)
else
DispatchMessageA(Msg);
end;
end;
end;
end;
procedure ProcessMessages;
var
Msg: TMsg;
begin
while ProcessMessage(Msg) do {loop};
end;
procedure TDataModule1.SFTPClientSuccess(Sender: TObject; Operation: TScSFTPOperation; const FileName: string; const Handle: TArray<System.Byte>; const Message: string);
begin
if Operation = TScSFTPOperation.opClosingHandle then
begin
FWorking := False;
FOK := True;
end;
end;
procedure TDataModule1.SFTPClientError(Sender: TObject; Operation: TScSFTPOperation; const FileName: string; const Handle: TArray<System.Byte>; ErrorCode: Integer; const ErrorMessage: string; var Fail: Boolean);
begin
FWorking := False;
end;
procedure TDataModule1.Upload;
var
WaitResult: DWORD;
Dummy: THandle;
begin
FWorking := True;
FOK := False;
SFTPClient.UploadFile(LocalFilePath, RemoteFilePath, True);
while FWorking do
begin
WaitResult := MsgWaitForMultipleObjects(0, Dummy, False, 1000, QS_ALLINPUT);
if WaitResult = WAIT_OBJECT_0 then
ProcessMessages;
end;
if FOK then
// ...and now file can be renamed
end;