From 1931b92ee4b2ac3b0d20ef172ace8002d39a2615 Mon Sep 17 00:00:00 2001 From: Data Dius <16731794+datadius@users.noreply.github.com> Date: Mon, 29 Apr 2024 22:00:34 +0200 Subject: [PATCH] update return when error to send nil fileinfos --- client.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 343d0c9..30e7b1a 100644 --- a/client.go +++ b/client.go @@ -355,12 +355,14 @@ func (a *Client) CopyFromRemoteFileInfos( r, err := session.StdoutPipe() if err != nil { + fileInfosCh <- nil errCh <- err return } in, err := session.StdinPipe() if err != nil { + fileInfosCh <- nil errCh <- err return } @@ -372,26 +374,32 @@ func (a *Client) CopyFromRemoteFileInfos( err = session.Start(fmt.Sprintf("%s -f %q", a.RemoteBinary, remotePath)) } if err != nil { + fileInfosCh <- nil errCh <- err return } err = Ack(in) if err != nil { + fileInfosCh <- nil errCh <- err return } fileInfo, err := ParseResponse(r, in) if err != nil { + fileInfosCh <- nil errCh <- err return } - fileInfosCh <- fileInfo + if fileInfo != nil { + fileInfosCh <- fileInfo + } err = Ack(in) if err != nil { + fileInfosCh <- nil errCh <- err return } @@ -402,18 +410,21 @@ func (a *Client) CopyFromRemoteFileInfos( _, err = CopyN(w, r, fileInfo.Size) if err != nil { + fileInfosCh <- nil errCh <- err return } err = Ack(in) if err != nil { + fileInfosCh <- nil errCh <- err return } err = session.Wait() if err != nil { + fileInfosCh <- nil errCh <- err return }