diff --git a/go.mod b/go.mod index f59a20dee74..bd0c6d2023e 100644 --- a/go.mod +++ b/go.mod @@ -321,3 +321,5 @@ require ( ) replace github.com/cs3org/go-cs3apis => github.com/c0rby/go-cs3apis v0.0.0-20230110100311-5b424f1baa35 + +replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20230513191305-7e887c838c63 diff --git a/go.sum b/go.sum index 2692d80e2a1..2730ca20f0e 100644 --- a/go.sum +++ b/go.sum @@ -626,8 +626,6 @@ github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= github.com/crewjam/saml v0.4.13 h1:TYHggH/hwP7eArqiXSJUvtOPNzQDyQ7vwmwEqlFWhMc= github.com/crewjam/saml v0.4.13/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA= -github.com/cs3org/reva/v2 v2.13.3-0.20230510083816-98d8707dea33 h1:y6xBTPOADX3jVX1faEwKsFD0PjSCSxDAf2jJaFYLAao= -github.com/cs3org/reva/v2 v2.13.3-0.20230510083816-98d8707dea33/go.mod h1:ZhUAORNpfKdMXO9LWcQta+DM77ArnqNnEB+b/Zgdmmk= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= @@ -1267,6 +1265,8 @@ github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQD github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= +github.com/micbar/reva/v2 v2.0.0-20230513191305-7e887c838c63 h1:dyZ5M/M1x6NGkMiagInLclbWPWCBycJpc9COtzDTOyM= +github.com/micbar/reva/v2 v2.0.0-20230513191305-7e887c838c63/go.mod h1:MoymB39kU/myG7LFkaCwqtoXQHct+/8uoZAvJEmNi+I= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/storageprovider/storageprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/storageprovider/storageprovider.go index eccb45ad321..b3fc565f7fe 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/storageprovider/storageprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/storageprovider/storageprovider.go @@ -282,10 +282,7 @@ func (s *service) InitiateFileDownload(ctx context.Context, req *provider.Initia protocol := &provider.FileDownloadProtocol{Expose: s.conf.ExposeDataServer} if utils.IsRelativeReference(req.Ref) { - // fill in storage provider id if it is missing - if req.GetRef().GetResourceId().GetStorageId() == "" { - req.GetRef().GetResourceId().StorageId = s.conf.MountID - } + s.addMissingStorageProviderID(req.GetRef().GetResourceId(), nil) protocol.Protocol = "spaces" u.Path = path.Join(u.Path, "spaces", storagespace.FormatResourceID(*req.Ref.ResourceId), req.Ref.Path) } else { @@ -517,9 +514,7 @@ func (s *service) CreateStorageSpace(ctx context.Context, req *provider.CreateSt }, nil } - if resp.StorageSpace != nil { - s.addMissingStorageProviderID(resp.StorageSpace.Root, resp.StorageSpace.Id) - } + s.addMissingStorageProviderID(resp.GetStorageSpace().GetRoot(), resp.GetStorageSpace().GetId()) return resp, nil } @@ -563,7 +558,7 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora continue } - s.addMissingStorageProviderID(sp.Root, sp.Id) + s.addMissingStorageProviderID(sp.GetRoot(), sp.GetId()) } return &provider.ListStorageSpacesResponse{ @@ -582,9 +577,7 @@ func (s *service) UpdateStorageSpace(ctx context.Context, req *provider.UpdateSt Msg("failed to update storage space") return nil, err } - if res.StorageSpace != nil { - s.addMissingStorageProviderID(res.StorageSpace.Root, res.StorageSpace.Id) - } + s.addMissingStorageProviderID(res.GetStorageSpace().GetRoot(), res.GetStorageSpace().GetId()) return res, nil } @@ -744,15 +737,9 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide }, nil } - // The storage driver might set the mount ID by itself, in which case skip this step - if md.Id.GetStorageId() == "" { - md.Id.StorageId = s.conf.MountID - } - - // The storage driver might set the mount ID by itself, in which case skip this step - if md.ParentId != nil && md.ParentId.GetStorageId() == "" { - md.ParentId.StorageId = s.conf.MountID - } + s.addMissingStorageProviderID(md.GetId(), nil) + s.addMissingStorageProviderID(md.GetParentId(), nil) + s.addMissingStorageProviderID(md.GetSpace().GetRoot(), nil) return &provider.StatResponse{ Status: status.NewOK(ctx), @@ -791,7 +778,9 @@ func (s *service) ListContainerStream(req *provider.ListContainerStreamRequest, } for _, md := range mds { - s.addMissingStorageProviderID(md.Id, nil) + s.addMissingStorageProviderID(md.GetId(), nil) + s.addMissingStorageProviderID(md.GetParentId(), nil) + s.addMissingStorageProviderID(md.GetSpace().GetRoot(), nil) res := &provider.ListContainerStreamResponse{ Info: md, Status: status.NewOK(ctx), @@ -816,10 +805,9 @@ func (s *service) ListContainer(ctx context.Context, req *provider.ListContainer } for _, i := range res.Infos { - s.addMissingStorageProviderID(i.Id, nil) - if i.ParentId != nil { - s.addMissingStorageProviderID(i.ParentId, nil) - } + s.addMissingStorageProviderID(i.GetId(), nil) + s.addMissingStorageProviderID(i.GetParentId(), nil) + s.addMissingStorageProviderID(i.GetSpace().GetRoot(), nil) } return res, nil } @@ -879,9 +867,7 @@ func (s *service) ListRecycleStream(req *provider.ListRecycleStreamRequest, ss p // TODO(labkode): CRITICAL: fill recycle info with storage provider. for _, item := range items { - if item.Ref != nil && item.Ref.ResourceId != nil { - s.addMissingStorageProviderID(item.Ref.GetResourceId(), nil) - } + s.addMissingStorageProviderID(item.GetRef().GetResourceId(), nil) res := &provider.ListRecycleStreamResponse{ RecycleItem: item, Status: status.NewOK(ctx), @@ -920,9 +906,7 @@ func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequ } for _, i := range items { - if i.Ref != nil && i.Ref.ResourceId != nil { - s.addMissingStorageProviderID(i.Ref.GetResourceId(), nil) - } + s.addMissingStorageProviderID(i.GetRef().GetResourceId(), nil) } res := &provider.ListRecycleResponse{ Status: status.NewOK(ctx), @@ -1220,7 +1204,7 @@ func (s *service) GetQuota(ctx context.Context, req *provider.GetQuotaRequest) ( func (s *service) addMissingStorageProviderID(resourceID *provider.ResourceId, spaceID *provider.StorageSpaceId) { // The storage driver might set the mount ID by itself, in which case skip this step - if resourceID.GetStorageId() == "" { + if resourceID != nil && resourceID.GetStorageId() == "" { resourceID.StorageId = s.conf.MountID if spaceID != nil { rid, _ := storagespace.ParseID(spaceID.GetOpaqueId()) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/cache.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/cache.go index cf6a7a12fe8..4f40bf016a4 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/cache.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/cache.go @@ -211,9 +211,6 @@ func (cache cacheStore) List(opts ...microstore.ListOption) ([]string, error) { if err != nil { return nil, err } - for i, key := range keys { - keys[i] = strings.TrimPrefix(key, cache.table) - } return keys, nil } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/node.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/node.go index bd3726e7bca..25a8a8e4ab7 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/node.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/node.go @@ -405,8 +405,8 @@ func (n *Node) Child(ctx context.Context, name string) (*Node, error) { return c, nil } -// Parent returns the parent node -func (n *Node) Parent() (p *Node, err error) { +// ParentWithReader returns the parent node +func (n *Node) ParentWithReader(r io.Reader) (p *Node, err error) { if n.ParentID == "" { return nil, fmt.Errorf("decomposedfs: root has no parent") } @@ -417,6 +417,9 @@ func (n *Node) Parent() (p *Node, err error) { SpaceRoot: n.SpaceRoot, } + // fill metadata cache using the reader + _, _ = p.XattrsWithReader(r) + // lookup name and parent id in extended attributes p.ParentID, _ = p.XattrString(prefixes.ParentidAttr) p.Name, _ = p.XattrString(prefixes.NameAttr) @@ -428,6 +431,11 @@ func (n *Node) Parent() (p *Node, err error) { return } +// Parent returns the parent node +func (n *Node) Parent() (p *Node, err error) { + return n.ParentWithReader(nil) +} + // Owner returns the space owner func (n *Node) Owner() *userpb.UserId { return n.SpaceRoot.owner diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/xattrs.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/xattrs.go index 506d3d047af..84565663187 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/xattrs.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/xattrs.go @@ -19,6 +19,7 @@ package node import ( + "io" "strconv" "github.com/pkg/xattr" @@ -84,21 +85,34 @@ func (n *Node) RemoveXattr(key string) error { return n.lu.MetadataBackend().Remove(n.InternalPath(), key) } -// Xattrs returns the extended attributes of the node. If the attributes have already +// XattrsWithReader returns the extended attributes of the node. If the attributes have already // been cached they are not read from disk again. -func (n *Node) Xattrs() (Attributes, error) { +func (n *Node) XattrsWithReader(r io.Reader) (Attributes, error) { if n.xattrsCache != nil { return n.xattrsCache, nil } - attrs, err := n.lu.MetadataBackend().All(n.InternalPath()) + var attrs Attributes + var err error + if r != nil { + attrs, err = n.lu.MetadataBackend().AllWithLockedSource(n.InternalPath(), r) + } else { + attrs, err = n.lu.MetadataBackend().All(n.InternalPath()) + } if err != nil { return nil, err } + n.xattrsCache = attrs return n.xattrsCache, nil } +// Xattrs returns the extended attributes of the node. If the attributes have already +// been cached they are not read from disk again. +func (n *Node) Xattrs() (Attributes, error) { + return n.XattrsWithReader(nil) +} + // Xattr returns an extended attribute of the node. If the attributes have already // been cached it is not read from disk again. func (n *Node) Xattr(key string) ([]byte, error) { diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go index fc49ef60ca1..12f264aeb0b 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go @@ -897,7 +897,7 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node, &provider.Reference{ ResourceId: &provider.ResourceId{ SpaceId: n.SpaceRoot.SpaceID, - OpaqueId: n.ID}, + OpaqueId: n.SpaceRoot.ID}, }, ) if err != nil { @@ -923,7 +923,7 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node, Id: &provider.StorageSpaceId{OpaqueId: ssID}, Root: &provider.ResourceId{ SpaceId: n.SpaceRoot.SpaceID, - OpaqueId: n.ID, + OpaqueId: n.SpaceRoot.ID, }, Name: sname, // SpaceType is read from xattr below @@ -974,7 +974,7 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node, Value: []byte(etag), } - spaceAttributes, err := n.Xattrs() + spaceAttributes, err := n.SpaceRoot.Xattrs() if err != nil { return nil, err } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go index d1212529456..90fc96b0514 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go @@ -731,7 +731,7 @@ func (t *Tree) Propagate(ctx context.Context, n *node.Node, sizeDiff int64) (err } }() - if n, err = n.Parent(); err != nil { + if n, err = n.ParentWithReader(f); err != nil { return err } diff --git a/vendor/modules.txt b/vendor/modules.txt index 74e472e6a66..3ab4f14dd0d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -349,7 +349,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.13.3-0.20230510083816-98d8707dea33 +# github.com/cs3org/reva/v2 v2.13.3-0.20230510083816-98d8707dea33 => github.com/micbar/reva/v2 v2.0.0-20230513191305-7e887c838c63 ## explicit; go 1.19 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime @@ -2124,3 +2124,4 @@ stash.kopano.io/kgol/oidc-go ## explicit; go 1.13 stash.kopano.io/kgol/rndm # github.com/cs3org/go-cs3apis => github.com/c0rby/go-cs3apis v0.0.0-20230110100311-5b424f1baa35 +# github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20230513191305-7e887c838c63