Skip to content

Commit

Permalink
Merge branch 'mafredri-mafredri/fix-copypassthru-data-race'
Browse files Browse the repository at this point in the history
  • Loading branch information
bramvdbogaerde committed Dec 19, 2022
2 parents 71df80a + 607fd1f commit 35e970e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ func (a *Client) CopyPassThru(ctx context.Context, r io.Reader, remotePath strin
if err != nil {
return err
}
w, err := a.Session.StdinPipe()
if err != nil {
return err
}
defer w.Close()

if passThru != nil {
r = passThru(r, size)
Expand All @@ -157,12 +162,6 @@ func (a *Client) CopyPassThru(ctx context.Context, r io.Reader, remotePath strin

go func() {
defer wg.Done()
w, err := a.Session.StdinPipe()
if err != nil {
errCh <- err
return
}

defer w.Close()

_, err = fmt.Fprintln(w, "C"+permissions, size, filename)
Expand Down

0 comments on commit 35e970e

Please sign in to comment.