mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
make deleting idempotent
This commit is contained in:
parent
b562edefd1
commit
a8fdca3b9f
2 changed files with 93 additions and 4 deletions
12
repo/repo.go
12
repo/repo.go
|
@ -325,7 +325,11 @@ func (h *Handler) deleteConfig(w http.ResponseWriter, r *http.Request) {
|
|||
cfg := h.getSubPath("config")
|
||||
|
||||
if err := os.Remove(cfg); err != nil {
|
||||
h.fileAccessError(w, err)
|
||||
// ignore not exist errors to make deleting idempotent, which is
|
||||
// necessary to properly handle request retries
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
h.fileAccessError(w, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -690,7 +694,11 @@ func (h *Handler) deleteBlob(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if err := os.Remove(path); err != nil {
|
||||
h.fileAccessError(w, err)
|
||||
// ignore not exist errors to make deleting idempotent, which is
|
||||
// necessary to properly handle request retries
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
h.fileAccessError(w, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue