properly close file in error handling of saveConfig and saveBlob (#385)

This commit is contained in:
Michael Eischer
2026-10-12 21:34:24 +02:00
committed by GitHub
parent 40b067eb5e
commit ef0bde0f5a
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -315,6 +315,7 @@ func (h *Handler) saveConfig(w http.ResponseWriter, r *http.Request) {
_, err = io.Copy(f, r.Body)
if err != nil {
_ = f.Close()
h.internalServerError(w, err)
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)
outFile, errCode, err := h.wrapFileWriter(r, tf)
if err != nil {
_ = tf.Close()
_ = os.Remove(tf.Name())
if h.opt.Debug {
log.Println(err)
}