Implement an append only mode.

This commit is contained in:
Kenny Keslar 2017-09-02 20:16:21 -05:00 committed by Zlatko Čalušić
parent cff373e8aa
commit 618b530b88
4 changed files with 18 additions and 0 deletions

View file

@ -194,6 +194,12 @@ func DeleteConfig(w http.ResponseWriter, r *http.Request) {
if Config.Debug {
log.Println("DeleteConfig()")
}
if Config.AppendOnly {
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
return
}
cfg, err := getPath(r, "config")
if err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
@ -372,6 +378,11 @@ func DeleteBlob(w http.ResponseWriter, r *http.Request) {
log.Println("DeleteBlob()")
}
if Config.AppendOnly && pat.Param(r, "type") != "locks" {
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
return
}
path, err := getFilePath(r, pat.Param(r, "type"), pat.Param(r, "name"))
if err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)