Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix creating new documents in the approvider #4479

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading