mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-20 19:26:17 +08:00
避免出现err==nil&&n==0的情况
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package multipart
|
||||
|
||||
import (
|
||||
"io"
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/textproto"
|
||||
"strings"
|
||||
"bytes"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SReader struct {
|
||||
@@ -88,12 +88,10 @@ func (r *SReader) Read(p []byte) (n int, err error) {
|
||||
if read < len(p) && !r.bodyEof {
|
||||
n, err := r.body.Read(p[read:])
|
||||
read += n
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
r.bodyEof = true
|
||||
} else {
|
||||
return read, err
|
||||
}
|
||||
if err == io.EOF || n == 0 {
|
||||
r.bodyEof = true
|
||||
} else {
|
||||
return read, err
|
||||
}
|
||||
}
|
||||
for read < len(p) && r.tailOffset < len(r.tail) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package multipart
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"strings"
|
||||
"bytes"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReader(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user