mirror of
https://github.com/restic/rest-server.git
synced 2026-10-15 15:10:07 -07:00
don't panic if saveConfig fails to open file
This commit is contained in:
+5
-1
@@ -305,11 +305,15 @@ func (h *Handler) saveConfig(w http.ResponseWriter, r *http.Request) {
|
||||
cfg := h.getSubPath("config")
|
||||
|
||||
f, err := os.OpenFile(cfg, os.O_CREATE|os.O_WRONLY|os.O_EXCL, h.opt.fileMode)
|
||||
if err != nil && os.IsExist(err) {
|
||||
if err != nil {
|
||||
if h.opt.Debug {
|
||||
log.Print(err)
|
||||
}
|
||||
if os.IsExist(err) {
|
||||
httpDefaultError(w, http.StatusForbidden)
|
||||
} else {
|
||||
h.internalServerError(w, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user