mirror of
https://github.com/restic/rest-server.git
synced 2026-09-26 22:11:37 -07:00
properly close file in error handling of saveConfig and saveBlob
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user