File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -1842,7 +1842,8 @@ func (f *File) readFromWithConcurrency(r io.Reader, concurrency int) (read int64
1842
1842
off := f .offset
1843
1843
1844
1844
for {
1845
- n , err := r .Read (b )
1845
+ // Fill the entire buffer.
1846
+ n , err := io .ReadFull (r , b )
1846
1847
1847
1848
if n > 0 {
1848
1849
read += int64 (n )
@@ -1868,7 +1869,7 @@ func (f *File) readFromWithConcurrency(r io.Reader, concurrency int) (read int64
1868
1869
}
1869
1870
1870
1871
if err != nil {
1871
- if err != io .EOF {
1872
+ if ! errors . Is ( err , io . EOF ) && ! errors . Is ( err , io .ErrUnexpectedEOF ) {
1872
1873
errCh <- rwErr {off , err }
1873
1874
}
1874
1875
return
@@ -2022,7 +2023,8 @@ func (f *File) ReadFrom(r io.Reader) (int64, error) {
2022
2023
2023
2024
var read int64
2024
2025
for {
2025
- n , err := r .Read (b )
2026
+ // Fill the entire buffer.
2027
+ n , err := io .ReadFull (r , b )
2026
2028
if n < 0 {
2027
2029
panic ("sftp.File: reader returned negative count from Read" )
2028
2030
}
@@ -2039,7 +2041,7 @@ func (f *File) ReadFrom(r io.Reader) (int64, error) {
2039
2041
}
2040
2042
2041
2043
if err != nil {
2042
- if err == io .EOF {
2044
+ if errors . Is ( err , io .EOF ) || errors . Is ( err , io . ErrUnexpectedEOF ) {
2043
2045
return read , nil // return nil explicitly.
2044
2046
}
2045
2047
You can’t perform that action at this time.
0 commit comments