Skip to content

Commit

Permalink
Make sure /app/new takes target as absolute path (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern authored Nov 26, 2021
1 parent db00a29 commit db635ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/app-abspath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Make sure /app/new takes `target` as absolute path

A mini-PR to make the `target` parameter absolute (by prepending `/` if missing).

https://github.com/cs3org/reva/pull/2305
7 changes: 7 additions & 0 deletions internal/http/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
return
}

// TODO(lopresti) if target is relative, currently the gateway fails to identify a storage provider (?)
// and just returns a CODE_INTERNAL error on InitiateFileUpload.
// Therefore for now make sure the target is absolute.
if target[0] != '/' {
target = "/" + target
}

// Create empty file via storageprovider
createReq := &provider.InitiateFileUploadRequest{
Ref: &provider.Reference{Path: target},
Expand Down
7 changes: 4 additions & 3 deletions internal/http/services/ocmd/reqres.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ type APIError struct {
}

// WriteError handles writing error responses
func WriteError(w http.ResponseWriter, r *http.Request, code APIErrorCode, message string, err error) {
if err != nil {
appctx.GetLogger(r.Context()).Error().Err(err).Msg(message)
func WriteError(w http.ResponseWriter, r *http.Request, code APIErrorCode, message string, e error) {
if e != nil {
appctx.GetLogger(r.Context()).Error().Err(e).Msg(message)
}

var encoded []byte
var err error
w.Header().Set("Content-Type", "application/json")
encoded, err = json.MarshalIndent(APIError{Code: code, Message: message}, "", " ")

Expand Down

0 comments on commit db635ef

Please sign in to comment.