properly close file in error handling of saveConfig and saveBlob

This commit is contained in:
Michael Eischer
2026-05-09 23:52:38 +02:00
parent 654fa16cb2
commit c143b82938
+3
View File
@@ -315,6 +315,7 @@ func (h *Handler) saveConfig(w http.ResponseWriter, r *http.Request) {
_, err = io.Copy(f, r.Body) _, err = io.Copy(f, r.Body)
if err != nil { if err != nil {
_ = f.Close()
h.internalServerError(w, err) h.internalServerError(w, err)
return return
} }
@@ -589,6 +590,8 @@ func (h *Handler) saveBlob(w http.ResponseWriter, r *http.Request) {
// ensure this blob does not put us over the quota size limit (if there is one) // ensure this blob does not put us over the quota size limit (if there is one)
outFile, errCode, err := h.wrapFileWriter(r, tf) outFile, errCode, err := h.wrapFileWriter(r, tf)
if err != nil { if err != nil {
_ = tf.Close()
_ = os.Remove(tf.Name())
if h.opt.Debug { if h.opt.Debug {
log.Println(err) log.Println(err)
} }