Skip to content

Commit

Permalink
update return when error to send nil fileinfos
Browse files Browse the repository at this point in the history
  • Loading branch information
datadius committed Apr 29, 2024
1 parent c053ea1 commit 1931b92
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 1931b92

Please sign in to comment.