From bd41401cb0ee041443c6a0b29d9ee017d8de3523 Mon Sep 17 00:00:00 2001 From: nexustar Date: Mon, 15 Aug 2022 15:45:15 +0800 Subject: [PATCH 1/2] server: fix not delete tmp file when upload package --- server/handler/tarball.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/server/handler/tarball.go b/server/handler/tarball.go index e98feda0a0..baa395670c 100644 --- a/server/handler/tarball.go +++ b/server/handler/tarball.go @@ -42,17 +42,13 @@ func (h *tarballUploader) upload(r *http.Request) (*simpleResponse, statusError) sid := mux.Vars(r)["sid"] logprinter.Infof("Uploading tarball, sid: %s", sid) - if err := r.ParseMultipartForm(MaxMemory); err != nil { - // TODO: log error here - return nil, ErrorInvalidTarball - } - file, handler, err := r.FormFile("file") if err != nil { // TODO: log error here return nil, ErrorInvalidTarball } defer file.Close() + defer r.MultipartForm.RemoveAll() if err := h.sm.Write(sid, handler.Filename, file); err != nil { logprinter.Errorf("Error to write tarball: %s", err.Error()) From 7e3e5bbe0f4f2ca15300b32cbe83b990324f6582 Mon Sep 17 00:00:00 2001 From: nexustar Date: Mon, 15 Aug 2022 16:11:36 +0800 Subject: [PATCH 2/2] ignore linter errcheck --- tools/check/golangci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/check/golangci.yaml b/tools/check/golangci.yaml index b5ad990650..f7bc9167c5 100644 --- a/tools/check/golangci.yaml +++ b/tools/check/golangci.yaml @@ -2,6 +2,9 @@ linters-settings: govet: enable: - nilness + errcheck: + exclude-functions: + - (*mime/multipart.Form).RemoveAll linters: disable-all: true