Skip to content

Commit

Permalink
Deprecate space_ref, use space instead (#2913)
Browse files Browse the repository at this point in the history
* get rid of space_ref, use space instead

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* changelog

Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj authored Jun 1, 2022
1 parent 6b47eff commit 0aa89cb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/space-ref-renaming.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Change: Rename ocs parameter "space_ref"

We decided to deprecate the parameter "space_ref". We decided to use
"space" parameter instead. The difference is that "space" must not contain
a "path". The "path" parameter can be used in combination with "space" to
create a relative path request

https://github.com/cs3org/reva/pull/2913
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,29 @@ func (h *Handler) startCacheWarmup(c cache.Warmup) {

func (h *Handler) extractReference(r *http.Request) (provider.Reference, error) {
var ref provider.Reference
if p := r.FormValue("path"); p != "" {
u := ctxpkg.ContextMustGetUser(r.Context())
ref = provider.Reference{
// FIXME ResourceId?
Path: path.Join(h.getHomeNamespace(u), p),

p, id := r.FormValue("path"), r.FormValue("space")
if p == "" && id == "" {
// NOTE: space_ref is deprecated and will be removed in ~2 weeks (1.6.22)
if sr := r.FormValue("space_ref"); sr != "" {
return storagespace.ParseReference(sr)
}
} else if spaceRef := r.FormValue("space_ref"); spaceRef != "" {
var err error
ref, err = storagespace.ParseReference(spaceRef)
return ref, errors.New("need path or space to extract reference")
}

if p != "" {
u := ctxpkg.ContextMustGetUser(r.Context())
ref.Path = path.Join(h.getHomeNamespace(u), p)
}

if id != "" {
rid, err := storagespace.ParseID(id)
if err != nil {
return provider.Reference{}, err
return ref, err
}
ref.ResourceId = &rid
}

return ref, nil
}

Expand Down Expand Up @@ -918,8 +928,9 @@ func (h *Handler) listSharesWithOthers(w http.ResponseWriter, r *http.Request) {

// shared with others
p := r.URL.Query().Get("path")
s := r.URL.Query().Get("space")
spaceRef := r.URL.Query().Get("space_ref")
if p != "" || spaceRef != "" {
if p != "" || s != "" || spaceRef != "" {
ref, err := h.extractReference(r)
if err != nil {
response.WriteOCSError(w, r, response.MetaBadRequest.StatusCode, errParsingSpaceReference.Error(), errParsingSpaceReference)
Expand Down

0 comments on commit 0aa89cb

Please sign in to comment.