fix: break resource create/update handlers on error (closes #1464)

This commit is contained in:
Oleg Lobanov 2021-07-24 15:33:54 +02:00
parent 6b19ab6613
commit 5072bbb2cb
No known key found for this signature in database
GPG Key ID: 7CC64E41212621B0
1 changed files with 0 additions and 10 deletions

View File

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
@ -96,10 +95,6 @@ func resourcePostHandler(fileCache FileCache) handleFunc {
return http.StatusForbidden, nil
}
defer func() {
_, _ = io.Copy(ioutil.Discard, r.Body)
}()
// Directories creation on POST.
if strings.HasSuffix(r.URL.Path, "/") {
err := d.user.Fs.MkdirAll(r.URL.Path, 0775)
@ -154,11 +149,6 @@ var resourcePutHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
return http.StatusForbidden, nil
}
defer func() {
_, _ = io.Copy(ioutil.Discard, r.Body)
}()
// Only allow PUT for files.
if strings.HasSuffix(r.URL.Path, "/") {
return http.StatusMethodNotAllowed, nil