all repos — flounder @ f63edd7303f49c0919c3009b93c93e6009f4e873

A small site builder for the Gemini protocol

Improve error handling on no file found

I think I was defer-ing too early
alex wennerberg alex@alexwennerberg.com
Mon, 01 Feb 2021 18:20:18 -0800
commit

f63edd7303f49c0919c3009b93c93e6009f4e873

parent

461036c5579c4f9e23c45e8d15499eea089b4f1c

1 files changed, 3 insertions(+), 3 deletions(-)

jump to
M http.gohttp.go

@@ -180,13 +180,13 @@ return

} r.ParseMultipartForm(10 << 6) // why does this not work file, fileHeader, err := r.FormFile("file") - fileName := filepath.Clean(fileHeader.Filename) - defer file.Close() if err != nil { log.Println(err) - renderError(w, err.Error(), http.StatusBadRequest) + renderError(w, "No file selected. Please go back and select a file.", http.StatusBadRequest) return } + fileName := filepath.Clean(fileHeader.Filename) + defer file.Close() dest, _ := ioutil.ReadAll(file) err = checkIfValidFile(user.Username, fileName, dest) if err != nil {