Skip to content

Commit

Permalink
use new space id format in ocdav
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Feb 12, 2024
1 parent e49ec28 commit 5839f5d
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions internal/http/services/owncloud/ocdav/dav.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package ocdav

import (
"context"
"encoding/base32"
"net/http"
"path"
"path/filepath"
Expand All @@ -31,6 +30,7 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/spaces"

"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/rhttp/router"
Expand Down Expand Up @@ -183,18 +183,18 @@ func (h *DavHandler) Handler(s *svc) http.Handler {
// the space is located
spaceID, relativeSpacePath := router.ShiftPath(r.URL.Path)

spacePath, err := getSpacePath(spaceID)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
_, base, ok := spaces.DecodeSpaceID(spaceID)
if !ok {
// TODO: bad request
panic("not yet implemented")
}

fullPath := filepath.Join(spacePath, relativeSpacePath)
fullPath := filepath.Join(base, relativeSpacePath)
r.URL.Path = fullPath

ctx = context.WithValue(ctx, ctxSpaceID, spaceID)
ctx = context.WithValue(ctx, ctxSpaceFullPath, fullPath)
ctx = context.WithValue(ctx, ctxSpacePath, spacePath)
ctx = context.WithValue(ctx, ctxSpacePath, base)
ctx = context.WithValue(ctx, ctxSpaceRelativePath, relativeSpacePath)
r = r.WithContext(ctx)
h.SpacesHandler.Handler(s).ServeHTTP(w, r)
Expand Down Expand Up @@ -343,14 +343,6 @@ func (h *DavHandler) Handler(s *svc) http.Handler {
})
}

func getSpacePath(spaceID string) (string, error) {
decoded, err := base32.StdEncoding.DecodeString(spaceID)
if err != nil {
return "", err
}
return string(decoded), nil
}

func getTokenStatInfo(ctx context.Context, client gatewayv1beta1.GatewayAPIClient, token string) (*provider.StatResponse, error) {
return client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{Path: path.Join("/public", token)}})
}
Expand Down

0 comments on commit 5839f5d

Please sign in to comment.