Skip to content
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
6 changes: 6 additions & 0 deletions changelog/unreleased/spaces-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: support for updating space

This PR adds support for updating spaces to libregraph, specifically the description and thumbnail of a space.
Additionally, the projects catalogue now directly implements the methods of the spaces registry.

https://github.com/cs3org/reva/pull/5260
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/coreos/go-oidc/v3 v3.14.1
github.com/creasty/defaults v1.8.0
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e
github.com/cs3org/go-cs3apis v0.0.0-20250626104136-a0b31b323c48
github.com/cs3org/go-cs3apis v0.0.0-20250811135935-5147e5c98678
github.com/dgraph-io/ristretto v0.2.0
github.com/dolthub/go-mysql-server v0.14.0
github.com/gdexlab/go-render v1.0.1
Expand Down Expand Up @@ -42,7 +42,7 @@ require (
github.com/nats-io/nats.go v1.43.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.38.0
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240425090020-dba6d1507c38
github.com/owncloud/libre-graph-api-go v1.0.5-0.20250217093259-fa3804be6c27
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.22.0
github.com/rs/cors v1.11.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,8 @@ github.com/creasty/defaults v1.8.0 h1:z27FJxCAa0JKt3utc0sCImAEb+spPucmKoOdLHvHYK
github.com/creasty/defaults v1.8.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e h1:tqSPWQeueWTKnJVMJffz4pz0o1WuQxJ28+5x5JgaHD8=
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20250626104136-a0b31b323c48 h1:ia8WkfK+9quVDRZzEXmjV9vmdwVbVyX26uVTIJlJm0o=
github.com/cs3org/go-cs3apis v0.0.0-20250626104136-a0b31b323c48/go.mod h1:DedpcqXl193qF/08Y04IO0PpxyyMu8+GrkD6kWK2MEQ=
github.com/cs3org/go-cs3apis v0.0.0-20250811135935-5147e5c98678 h1:MVTpLBAmZMvDY+5TW1LYCSlitKikwX0/Sor8LSqeCJ4=
github.com/cs3org/go-cs3apis v0.0.0-20250811135935-5147e5c98678/go.mod h1:DedpcqXl193qF/08Y04IO0PpxyyMu8+GrkD6kWK2MEQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -1405,8 +1405,8 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240425090020-dba6d1507c38 h1:Ld9bPh0c4y1H22mhiWZBw4AoupWjg8L0WLKX0hfbJho=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240425090020-dba6d1507c38/go.mod h1:yXI+rmE8yYx+ZsGVrnCpprw/gZMcxjwntnX2y2+VKxY=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20250217093259-fa3804be6c27 h1:ID8s5lGBntmrlI6TbDAjTzRyHucn3bVM2wlW+HBplv4=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20250217093259-fa3804be6c27/go.mod h1:+gT+x62AS9u2Farh9wE2uYmgdvTg0MQgsSI62D+xoRg=
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
Expand Down
9 changes: 7 additions & 2 deletions internal/grpc/services/spacesregistry/spacesregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,15 @@ func (s *service) listSpacesByType(ctx context.Context, user *userpb.User, space
sp = append(sp, space)
}
} else if spaceType == spaces.SpaceTypeProject {
projects, err := s.projects.ListProjects(ctx, user)
resp, err := s.projects.ListStorageSpaces(ctx, &provider.ListStorageSpacesRequest{})
if err != nil {
return nil, err
}
if resp.Status.Code != rpcv1beta1.Code_CODE_OK {
return nil, fmt.Errorf("%s: %s", resp.Status.Code.String(), resp.Status.Message)
}

projects := resp.StorageSpaces
if err := s.decorateProjects(ctx, projects); err != nil {
return nil, err
}
Expand Down Expand Up @@ -305,7 +310,7 @@ func (s *service) userSpace(ctx context.Context, user *userpb.User) (*provider.S
}

func (s *service) UpdateStorageSpace(ctx context.Context, req *provider.UpdateStorageSpaceRequest) (*provider.UpdateStorageSpaceResponse, error) {
return nil, errors.New("not yet implemented")
return s.projects.UpdateStorageSpace(ctx, req)
}

func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorageSpaceRequest) (*provider.DeleteStorageSpaceResponse, error) {
Expand Down
42 changes: 30 additions & 12 deletions internal/http/services/owncloud/ocdav/dav.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,41 @@ func (h *DavHandler) Handler(s *svc) http.Handler {
r = r.WithContext(ctx)
h.TrashbinHandler.Handler(s).ServeHTTP(w, r)
default:
// path is of type: space_id/relative/path/from/space
// the space_id is the base64 encode of the path where
// the space is located
// there are two possible types of path
// 1) path is of type: space_id/relative/path/from/space
// the space_id is the base64 encode of the path where
// the space is located
// 2) path is of type: resource_id/relative/path
// here, resource_id is the encoded resource id of a folder
// i.e. in the form of storage$space_id!inode
// and the relative path is relative to this folder

_, base, ok := spaces.DecodeStorageSpaceID(head)
if !ok {
w.WriteHeader(http.StatusBadRequest)
return
if ok {
// this is case (1)
ctx = context.WithValue(ctx, ctxSpaceID, head)
fullPath := filepath.Join(base, r.URL.Path)
// like this, we can use the existing DAV handler
// we replace the space id with it's actual path in the URL
r.URL.Path = fullPath

// We support doing a PUT and a PROPFIND on a resource ID (eg eos$space!inode/file.txt)
} else if r.Method == http.MethodPut || r.Method == MethodPropfind {
// If it's not a space ID, we try to parse it as a resource ID, i.e. case (2)
var storageId, itemId string
storageId, base, itemId, ok = spaces.DecodeResourceID(head)
if !ok {
w.WriteHeader(http.StatusBadRequest)
return
}

spaceId := spaces.EncodeSpaceID(base)
ctx = context.WithValue(ctx, ctxSpaceID, spaceId)
ctx = context.WithValue(ctx, ctxStorageId, storageId)
ctx = context.WithValue(ctx, ctxResourceOpaqueId, itemId)
}

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

ctx = context.WithValue(ctx, ctxSpaceID, head)
ctx = context.WithValue(ctx, ctxSpaceFullPath, fullPath)
ctx = context.WithValue(ctx, ctxSpacePath, base)
ctx = context.WithValue(ctx, ctxSpaceRelativePath, r.URL.Path)
r = r.WithContext(ctx)
h.SpacesHandler.Handler(s).ServeHTTP(w, r)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/http/services/owncloud/ocdav/ocdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ const (
ctxKeyBaseURI ctxKey = iota
ctxSpaceID
ctxSpacePath
ctxSpaceFullPath
ctxSpaceRelativePath
ctxOCM
ctxPublicLink
ctxStorageId
ctxResourceOpaqueId
)

var (
Expand Down
13 changes: 10 additions & 3 deletions internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,18 @@ const (
// ns is the namespace that is prefixed to the path in the cs3 namespace.
func (s *svc) handlePathPropfind(w http.ResponseWriter, r *http.Request, ns string) {
ctx := r.Context()

fn := path.Join(ns, r.URL.Path)
ref := &provider.Reference{}

sublog := appctx.GetLogger(ctx).With().Str("path", fn).Logger()
// We check if the PROPFIND was made to a resource ID instead of a path
if r, ok := requestWasMadeToResourceId(ctx, fn); ok {
ref = r
} else {
ref.Path = fn
}

sublog := appctx.GetLogger(ctx).With().Any("ref", ref).Logger()

pf, status, err := readPropfind(r.Body)
if err != nil {
Expand All @@ -83,8 +92,6 @@ func (s *svc) handlePathPropfind(w http.ResponseWriter, r *http.Request, ns stri
return
}

ref := &provider.Reference{Path: fn}

parentInfo, resourceInfos, ok := s.getResourceInfos(ctx, w, r, pf, ref, false, sublog)
if !ok {
// getResourceInfos handles responses in case of an error so we can just return here.
Expand Down
11 changes: 9 additions & 2 deletions internal/http/services/owncloud/ocdav/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,18 @@ func isContentRange(r *http.Request) bool {

func (s *svc) handlePathPut(w http.ResponseWriter, r *http.Request, ns string) {
ctx := r.Context()

fn := path.Join(ns, r.URL.Path)
ref := &provider.Reference{}

sublog := appctx.GetLogger(ctx).With().Str("path", fn).Logger()
// We check if the PUT was made to a resource ID instead of a path
if r, ok := requestWasMadeToResourceId(ctx, fn); ok {
ref = r
} else {
ref.Path = fn
}

ref := &provider.Reference{Path: fn}
sublog := appctx.GetLogger(ctx).With().Any("ref", ref).Logger()

s.handlePut(ctx, w, r, ref, sublog)
}
Expand Down
20 changes: 20 additions & 0 deletions internal/http/services/owncloud/ocdav/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import (
"context"
"fmt"
"net/http"
"path"

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
storageProvider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v3/pkg/rhttp/router"
"github.com/cs3org/reva/v3/pkg/utils"
Expand Down Expand Up @@ -130,3 +132,21 @@ func (s *svc) lookUpStorageSpaceReference(ctx context.Context, spaceID string, r
Path: utils.MakeRelativePath(relativePath),
}, lSSRes.Status, nil
}

func requestWasMadeToResourceId(ctx context.Context, fn string) (ref *provider.Reference, ok bool) {
if opaqueId := ctx.Value(ctxResourceOpaqueId); opaqueId != nil {
storageId := ctx.Value(ctxStorageId)
if storageId != nil {
ref := &provider.Reference{
// We make the path relative
Path: path.Join(".", fn),
ResourceId: &provider.ResourceId{
StorageId: storageId.(string),
OpaqueId: opaqueId.(string),
},
}
return ref, true
}
}
return nil, false
}
Loading