Skip to content

Commit

Permalink
don't block file info channel
Browse files Browse the repository at this point in the history
  • Loading branch information
datadius committed Apr 29, 2024
1 parent 1931b92 commit 6ea89a2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (a *Client) CopyFromRemoteFileInfos(

wg := sync.WaitGroup{}
errCh := make(chan error, 4)
fileInfosCh := make(chan *FileInfos, 1)
fileInfosCh := make(chan *FileInfos, 4)

wg.Add(1)
go func() {
Expand Down Expand Up @@ -395,11 +395,12 @@ func (a *Client) CopyFromRemoteFileInfos(

if fileInfo != nil {
fileInfosCh <- fileInfo
} else {
fileInfosCh <- nil
}

err = Ack(in)
if err != nil {
fileInfosCh <- nil
errCh <- err
return
}
Expand All @@ -410,21 +411,18 @@ 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 6ea89a2

Please sign in to comment.