Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,8 @@ func (f *File) readFromWithConcurrency(r io.Reader, concurrency int) (read int64
off := f.offset

for {
n, err := r.Read(b)
// Fill the entire buffer.
n, err := io.ReadFull(r, b)

if n > 0 {
read += int64(n)
Expand All @@ -1868,7 +1869,7 @@ func (f *File) readFromWithConcurrency(r io.Reader, concurrency int) (read int64
}

if err != nil {
if err != io.EOF {
if !errors.Is(err, io.EOF) && !errors.Is(err, io.ErrUnexpectedEOF) {
errCh <- rwErr{off, err}
}
return
Expand Down Expand Up @@ -2022,7 +2023,8 @@ func (f *File) ReadFrom(r io.Reader) (int64, error) {

var read int64
for {
n, err := r.Read(b)
// Fill the entire buffer.
n, err := io.ReadFull(r, b)
if n < 0 {
panic("sftp.File: reader returned negative count from Read")
}
Expand All @@ -2039,7 +2041,7 @@ func (f *File) ReadFrom(r io.Reader) (int64, error) {
}

if err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
return read, nil // return nil explicitly.
}

Expand Down