Skip to content

Commit

Permalink
Merge pull request #4479 from aduffeck/fix-appprovider
Browse files Browse the repository at this point in the history
Fix creating new documents in the approvider
  • Loading branch information
butonic committed Jan 26, 2024
2 parents 7fd434a + f2c52dd commit bec9d4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-creating-documents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix creating documents in the approvider

We fixed a problem with the approvider where an error was reported to the user even though the file was created properly.

https://github.com/cs3org/reva/pull/4479
3 changes: 1 addition & 2 deletions internal/http/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,8 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
return
}
defer httpRes.Body.Close()
if httpRes.StatusCode == http.StatusForbidden {
if httpRes.StatusCode == http.StatusBadRequest {
// the file upload was already finished since it is a zero byte file
// TODO: why do we get a 401 then!?
} else if httpRes.StatusCode != http.StatusOK {
writeError(w, r, appErrorServerError, "failed to create the file", nil)
return
Expand Down
7 changes: 7 additions & 0 deletions pkg/rhttp/datatx/manager/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) {
defer func() {
metrics.UploadsActive.Sub(1)
}()

if r.ContentLength == 0 {
sublog.Info().Msg("received invalid 0-byte PUT request")
w.WriteHeader(http.StatusBadRequest)
return
}

fn := r.URL.Path
defer r.Body.Close()

Expand Down

0 comments on commit bec9d4c

Please sign in to comment.