From 7e6594f3c7ba2ba19e5ca682d478b5d1f8a9072d Mon Sep 17 00:00:00 2001 From: grumbulon Date: Sat, 21 Jan 2023 11:21:41 -0500 Subject: [PATCH] move defer file.Close() to before validateContentType because that could cause problems --- internal/api/zone.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/api/zone.go b/internal/api/zone.go index 1a152a0..e1512d4 100644 --- a/internal/api/zone.go +++ b/internal/api/zone.go @@ -65,13 +65,14 @@ func ReceiveFile(w http.ResponseWriter, r *http.Request) { return } + defer file.Close() //nolint: errcheck + ok := validateContentType(file) if !ok { http.Error(w, "file must be text/plain", http.StatusUnsupportedMediaType) return } - defer file.Close() //nolint: errcheck name := strings.Split(header.Filename, ".")