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

Deprecate space_ref, use space instead #2913

Merged
merged 2 commits into from
Jun 1, 2022
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
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