From 2327c0756bf0d4da8d376377948bcbcc0a553d6e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 5 Apr 2021 23:24:26 -0700 Subject: [PATCH] fix to avoid loop --- weed/server/filer_server_handlers_write_upload.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/weed/server/filer_server_handlers_write_upload.go b/weed/server/filer_server_handlers_write_upload.go index 03db942c6..81b2ce1b0 100644 --- a/weed/server/filer_server_handlers_write_upload.go +++ b/weed/server/filer_server_handlers_write_upload.go @@ -74,10 +74,10 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque lock.Unlock() // handle read errors if readErr != nil { + if err == nil { + err = readErr + } if readErr != io.EOF { - if err == nil { - err = readErr - } resultsChan <- &ChunkCreationResult{ err: readErr, } @@ -86,6 +86,9 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque } if len(data) == 0 { readErr = io.EOF + if err == nil { + err = readErr + } return } @@ -120,6 +123,10 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque waitForAllData.Wait() + if err == io.EOF { + err = nil + } + return fileChunks, md5Hash, readOffset, err, nil }