From 0346db462bbbad63631d39623ea75ebf10f8ef7f Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 26 Jan 2021 11:35:05 +0300 Subject: [PATCH] Add cleanup multipart form on defer Signed-off-by: Evgeniy Kulikov --- upload.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/upload.go b/upload.go index 128c3eb..f5e4324 100644 --- a/upload.go +++ b/upload.go @@ -64,6 +64,12 @@ func (a *app) upload(c *fasthttp.RequestCtx) { log.Debug("close temporary file", zap.Error(tmp.Close())) log.Debug("remove temporary file", zap.Error(os.RemoveAll(tmpName))) + + if form == nil { + return + } + + log.Debug("cleanup multipart form", zap.Error(form.RemoveAll())) }() if form, err = c.MultipartForm(); err != nil {