Skip to content

Commit 7774846

Browse files
committed
fix(serverHandler/upload): stop reading next part if error occured
0 parts will make loop endless, just break it if error occured. When this happened, an error "multipart: NextPart: EOF" which wrapps `io.EOF` is returned. Although we can use `errors.Is(err, io.EOF)` to detect, we need to prevent doing this currently, since `errors.Is` was introduced in Go 1.13 which does not support Windows XP platform.
1 parent a7a7985 commit 7774846

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/serverHandler/upload.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ func (h *handler) saveUploadFiles(fsPrefix string, overwriteExists bool, r *http
4444

4545
for {
4646
part, err := reader.NextPart()
47-
if err == io.EOF {
48-
break
49-
}
5047
if err != nil {
51-
errs = append(errs, err)
52-
continue
48+
if err != io.EOF {
49+
errs = append(errs, err)
50+
}
51+
break
5352
}
5453

5554
filename := part.FileName()

0 commit comments

Comments
 (0)