Bump reva
This commit is contained in:
Generated
Vendored
+10
-10
@@ -648,40 +648,40 @@ func (s *svc) CreateContainer(ctx context.Context, req *provider.CreateContainer
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (s *svc) AddFavorite(ctx context.Context, req *provider.AddFavoriteRequest) (*provider.AddFavoriteResponse, error) {
|
||||
func (s *svc) AddLabel(ctx context.Context, req *provider.AddLabelRequest) (*provider.AddLabelResponse, error) {
|
||||
var c provider.ProviderAPIClient
|
||||
var err error
|
||||
c, _, req.Ref, err = s.findAndUnwrap(ctx, req.Ref)
|
||||
if err != nil {
|
||||
return &provider.AddFavoriteResponse{
|
||||
return &provider.AddLabelResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, fmt.Sprintf("gateway could not find space for ref=%+v", req.Ref), err),
|
||||
}, nil
|
||||
}
|
||||
|
||||
res, err := c.AddFavorite(ctx, req)
|
||||
res, err := c.AddLabel(ctx, req)
|
||||
if err != nil {
|
||||
return &provider.AddFavoriteResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "gateway could not call AddFavorite", err),
|
||||
return &provider.AddLabelResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "gateway could not call AddLabel", err),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (s *svc) RemoveFavorite(ctx context.Context, req *provider.RemoveFavoriteRequest) (*provider.RemoveFavoriteResponse, error) {
|
||||
func (s *svc) RemoveLabel(ctx context.Context, req *provider.RemoveLabelRequest) (*provider.RemoveLabelResponse, error) {
|
||||
var c provider.ProviderAPIClient
|
||||
var err error
|
||||
c, _, req.Ref, err = s.findAndUnwrap(ctx, req.Ref)
|
||||
if err != nil {
|
||||
return &provider.RemoveFavoriteResponse{
|
||||
return &provider.RemoveLabelResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, fmt.Sprintf("gateway could not find space for ref=%+v", req.Ref), err),
|
||||
}, nil
|
||||
}
|
||||
|
||||
res, err := c.RemoveFavorite(ctx, req)
|
||||
res, err := c.RemoveLabel(ctx, req)
|
||||
if err != nil {
|
||||
return &provider.RemoveFavoriteResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "gateway could not call RemoveFavorite", err),
|
||||
return &provider.RemoveLabelResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "gateway could not call RemoveLabel", err),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Generated
Vendored
+4
-4
@@ -264,9 +264,9 @@ func (c *cachedAPIClient) GetHome(ctx context.Context, in *provider.GetHomeReque
|
||||
func (c *cachedAPIClient) TouchFile(ctx context.Context, in *provider.TouchFileRequest, opts ...grpc.CallOption) (*provider.TouchFileResponse, error) {
|
||||
return c.c.TouchFile(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) AddFavorite(ctx context.Context, in *provider.AddFavoriteRequest, opts ...grpc.CallOption) (*provider.AddFavoriteResponse, error) {
|
||||
return c.c.AddFavorite(ctx, in, opts...)
|
||||
func (c *cachedAPIClient) AddLabel(ctx context.Context, in *provider.AddLabelRequest, opts ...grpc.CallOption) (*provider.AddLabelResponse, error) {
|
||||
return c.c.AddLabel(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) RemoveFavorite(ctx context.Context, in *provider.RemoveFavoriteRequest, opts ...grpc.CallOption) (*provider.RemoveFavoriteResponse, error) {
|
||||
return c.c.RemoveFavorite(ctx, in, opts...)
|
||||
func (c *cachedAPIClient) RemoveLabel(ctx context.Context, in *provider.RemoveLabelRequest, opts ...grpc.CallOption) (*provider.RemoveLabelResponse, error) {
|
||||
return c.c.RemoveLabel(ctx, in, opts...)
|
||||
}
|
||||
|
||||
Generated
Vendored
+2
-2
@@ -929,11 +929,11 @@ func (s *service) GetQuota(ctx context.Context, req *provider.GetQuotaRequest) (
|
||||
return nil, gstatus.Errorf(codes.Unimplemented, "method not implemented")
|
||||
}
|
||||
|
||||
func (s *service) AddFavorite(ctx context.Context, req *provider.AddFavoriteRequest) (*provider.AddFavoriteResponse, error) {
|
||||
func (s *service) AddLabel(ctx context.Context, req *provider.AddLabelRequest) (*provider.AddLabelResponse, error) {
|
||||
return nil, gstatus.Errorf(codes.Unimplemented, "method not implemented")
|
||||
}
|
||||
|
||||
func (s *service) RemoveFavorite(ctx context.Context, req *provider.RemoveFavoriteRequest) (*provider.RemoveFavoriteResponse, error) {
|
||||
func (s *service) RemoveLabel(ctx context.Context, req *provider.RemoveLabelRequest) (*provider.RemoveLabelResponse, error) {
|
||||
return nil, gstatus.Errorf(codes.Unimplemented, "method not implemented")
|
||||
}
|
||||
|
||||
|
||||
Generated
Vendored
+2
-2
@@ -1035,11 +1035,11 @@ func (s *service) GetQuota(ctx context.Context, req *provider.GetQuotaRequest) (
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *service) AddFavorite(ctx context.Context, req *provider.AddFavoriteRequest) (*provider.AddFavoriteResponse, error) {
|
||||
func (s *service) AddLabel(ctx context.Context, req *provider.AddLabelRequest) (*provider.AddLabelResponse, error) {
|
||||
return nil, gstatus.Errorf(codes.Unimplemented, "method not implemented")
|
||||
}
|
||||
|
||||
func (s *service) RemoveFavorite(ctx context.Context, req *provider.RemoveFavoriteRequest) (*provider.RemoveFavoriteResponse, error) {
|
||||
func (s *service) RemoveLabel(ctx context.Context, req *provider.RemoveLabelRequest) (*provider.RemoveLabelResponse, error) {
|
||||
return nil, gstatus.Errorf(codes.Unimplemented, "method not implemented")
|
||||
}
|
||||
|
||||
|
||||
Generated
Vendored
+12
-12
@@ -706,32 +706,32 @@ func (s *Service) TouchFile(ctx context.Context, req *provider.TouchFileRequest)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) AddFavorite(ctx context.Context, req *provider.AddFavoriteRequest) (*provider.AddFavoriteResponse, error) {
|
||||
appctx.GetLogger(ctx).Debug().Msg("AddFavorite")
|
||||
func (s *Service) AddLabel(ctx context.Context, req *provider.AddLabelRequest) (*provider.AddLabelResponse, error) {
|
||||
appctx.GetLogger(ctx).Debug().Msg("AddLabel")
|
||||
|
||||
err := s.Storage.AddFavorite(ctx, req.Ref, req.UserId)
|
||||
err := s.Storage.AddLabel(ctx, req.Ref, req.UserId, req.Label)
|
||||
if err != nil {
|
||||
return &provider.AddFavoriteResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "add favorite", err),
|
||||
return &provider.AddLabelResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "add label", err),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &provider.AddFavoriteResponse{
|
||||
return &provider.AddLabelResponse{
|
||||
Status: status.NewOK(ctx),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) RemoveFavorite(ctx context.Context, req *provider.RemoveFavoriteRequest) (*provider.RemoveFavoriteResponse, error) {
|
||||
appctx.GetLogger(ctx).Debug().Msg("RemoveFavorite")
|
||||
func (s *Service) RemoveLabel(ctx context.Context, req *provider.RemoveLabelRequest) (*provider.RemoveLabelResponse, error) {
|
||||
appctx.GetLogger(ctx).Debug().Msg("RemoveLabel")
|
||||
|
||||
err := s.Storage.RemoveFavorite(ctx, req.Ref, req.UserId)
|
||||
err := s.Storage.RemoveLabel(ctx, req.Ref, req.UserId, req.Label)
|
||||
if err != nil {
|
||||
return &provider.RemoveFavoriteResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "remove favorite", err),
|
||||
return &provider.RemoveLabelResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "remove label", err),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &provider.RemoveFavoriteResponse{
|
||||
return &provider.RemoveLabelResponse{
|
||||
Status: status.NewOK(ctx),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Generated
Vendored
+10
-8
@@ -11,32 +11,34 @@ import (
|
||||
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
|
||||
)
|
||||
|
||||
// FavoriteAdded is emitted when a user added a resource to their favorites
|
||||
type FavoriteAdded struct {
|
||||
// LabelAdded is emitted when a user adds a label to a resource
|
||||
type LabelAdded struct {
|
||||
Ref *provider.Reference
|
||||
Label string
|
||||
Executant *user.UserId
|
||||
UserID *user.UserId
|
||||
Timestamp *types.Timestamp
|
||||
}
|
||||
|
||||
// Unmarshal to fulfill umarshaller interface
|
||||
func (FavoriteAdded) Unmarshal(v []byte) (interface{}, error) {
|
||||
e := FavoriteAdded{}
|
||||
func (LabelAdded) Unmarshal(v []byte) (interface{}, error) {
|
||||
e := LabelAdded{}
|
||||
err := json.Unmarshal(v, &e)
|
||||
return e, err
|
||||
}
|
||||
|
||||
// FavoriteRemoved is emitted when a user removed a resource from their favorites
|
||||
type FavoriteRemoved struct {
|
||||
// LabelRemoved is emitted when a user removes a label from a resource
|
||||
type LabelRemoved struct {
|
||||
Ref *provider.Reference
|
||||
Label string
|
||||
Executant *user.UserId
|
||||
UserID *user.UserId
|
||||
Timestamp *types.Timestamp
|
||||
}
|
||||
|
||||
// Unmarshal to fulfill umarshaller interface
|
||||
func (FavoriteRemoved) Unmarshal(v []byte) (interface{}, error) {
|
||||
e := FavoriteRemoved{}
|
||||
func (LabelRemoved) Unmarshal(v []byte) (interface{}, error) {
|
||||
e := LabelRemoved{}
|
||||
err := json.Unmarshal(v, &e)
|
||||
return e, err
|
||||
}
|
||||
+4
-4
@@ -610,10 +610,10 @@ func (d *driver) DeleteStorageSpace(ctx context.Context, req *provider.DeleteSto
|
||||
return errtypes.NotSupported("operation not supported")
|
||||
}
|
||||
|
||||
func (d *driver) AddFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
func (d *driver) AddLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
func (d *driver) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
func (d *driver) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
// Copyright 2026 OpenCloud GmbH <mail@opencloud.eu>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff"
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
)
|
||||
|
||||
func NewNatsKeyValue(c Config) (jetstream.KeyValue, error) {
|
||||
nodes := strings.Join(c.Nodes, ",")
|
||||
if nodes == "" {
|
||||
return nil, errors.New("at least one node is required")
|
||||
}
|
||||
opts := []nats.Option{}
|
||||
if c.AuthUsername != "" || c.AuthPassword != "" {
|
||||
opts = append(opts, nats.UserInfo(c.AuthUsername, c.AuthPassword))
|
||||
}
|
||||
|
||||
if c.TLSEnabled {
|
||||
tlsConfig := &tls.Config{
|
||||
InsecureSkipVerify: c.TLSInsecure,
|
||||
}
|
||||
if c.TLSRootCACertificate != "" {
|
||||
caCert, err := os.ReadFile(c.TLSRootCACertificate)
|
||||
if err == nil {
|
||||
caCertPool := x509.NewCertPool()
|
||||
caCertPool.AppendCertsFromPEM(caCert)
|
||||
tlsConfig.RootCAs = caCertPool
|
||||
}
|
||||
}
|
||||
opts = append(opts, nats.Secure(tlsConfig))
|
||||
}
|
||||
|
||||
var js jetstream.JetStream
|
||||
o := func() error {
|
||||
nc, err := nats.Connect(nodes, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
js, err = jetstream.New(nc)
|
||||
return err
|
||||
}
|
||||
|
||||
err := backoff.Retry(o, backoff.NewExponentialBackOff())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewNatsKeyValueFromJetStream(c, js)
|
||||
}
|
||||
|
||||
func NewNatsKeyValueFromJetStream(c Config, js jetstream.JetStream) (jetstream.KeyValue, error) {
|
||||
var err error
|
||||
var kv jetstream.KeyValue
|
||||
o := func() error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
kv, err = js.KeyValue(ctx, c.Database)
|
||||
if err != nil {
|
||||
kvConfig := jetstream.KeyValueConfig{
|
||||
Bucket: c.Database,
|
||||
TTL: 0, // we don't do TTLs for this store
|
||||
}
|
||||
if c.DisablePersistence {
|
||||
kvConfig.Storage = jetstream.MemoryStorage
|
||||
}
|
||||
if c.Size > 0 {
|
||||
kvConfig.MaxBytes = int64(c.Size)
|
||||
}
|
||||
kv, err = js.CreateKeyValue(ctx, kvConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
err = backoff.Retry(o, backoff.NewExponentialBackOff())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return kv, nil
|
||||
}
|
||||
+4
-4
@@ -603,12 +603,12 @@ func (fs *cephfs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Refe
|
||||
return getRevaError(err)
|
||||
}
|
||||
|
||||
func (fs *cephfs) AddFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
func (fs *cephfs) AddLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
func (fs *cephfs) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
func (fs *cephfs) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
func (fs *cephfs) EmptyRecycle(ctx context.Context, ref *provider.Reference) error {
|
||||
|
||||
+4
-4
@@ -125,12 +125,12 @@ func (fs *hellofs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Ref
|
||||
return errtypes.NotSupported("unimplemented")
|
||||
}
|
||||
|
||||
func (fs *hellofs) AddFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
func (fs *hellofs) AddLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
func (fs *hellofs) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
func (fs *hellofs) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
// locks
|
||||
|
||||
+6
-6
@@ -862,14 +862,14 @@ func (nc *StorageDriver) Unlock(ctx context.Context, ref *provider.Reference, lo
|
||||
return errtypes.NotSupported("unimplemented")
|
||||
}
|
||||
|
||||
// AddFavorite adds a favourite to a resource
|
||||
func (nc *StorageDriver) AddFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
// AddLabel adds a label to a resource
|
||||
func (nc *StorageDriver) AddLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
// RemoveFavorite removes a favourite from a resource
|
||||
func (nc *StorageDriver) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
// RemoveLabel removes a label from a resource
|
||||
func (nc *StorageDriver) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
// ListStorageSpaces as defined in the storage.FS interface
|
||||
|
||||
+4
-4
@@ -1137,12 +1137,12 @@ func (fs *owncloudsqlfs) UnsetArbitraryMetadata(ctx context.Context, ref *provid
|
||||
}
|
||||
}
|
||||
|
||||
func (fs *owncloudsqlfs) AddFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
func (fs *owncloudsqlfs) AddLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
func (fs *owncloudsqlfs) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
func (fs *owncloudsqlfs) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
// GetLock returns an existing lock on the given reference
|
||||
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
// Copyright 2018-2021 CERN
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// In applying this license, CERN does not waive the privileges and immunities
|
||||
// granted to it by virtue of its status as an Intergovernmental Organization
|
||||
// or submit itself to any jurisdiction.
|
||||
|
||||
package idcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base32"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/appctx"
|
||||
)
|
||||
|
||||
type IDCache struct {
|
||||
kv jetstream.KeyValue
|
||||
}
|
||||
|
||||
// NewStoreIDCache returns a new StoreIDCache
|
||||
func NewStoreIDCache(kv jetstream.KeyValue) (*IDCache, error) {
|
||||
return &IDCache{
|
||||
kv: kv,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Delete removes an entry from the cache
|
||||
func (c *IDCache) Delete(ctx context.Context, spaceID, nodeID string) error {
|
||||
var rerr error
|
||||
v, err := c.kv.Get(ctx, cacheKey(spaceID, nodeID))
|
||||
if err == nil {
|
||||
rerr = c.kv.Purge(ctx, reverseCacheKey(string(v.Value())))
|
||||
}
|
||||
|
||||
err = c.kv.Purge(ctx, cacheKey(spaceID, nodeID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return rerr
|
||||
}
|
||||
|
||||
// DeleteByPath removes an entry from the cache
|
||||
func (c *IDCache) DeleteByPath(ctx context.Context, path string) error {
|
||||
baseKey := reverseCacheKey(path)
|
||||
|
||||
spaceID, nodeID, ok := c.GetByPath(ctx, path)
|
||||
if !ok {
|
||||
appctx.GetLogger(ctx).Error().Str("record", path).Msg("could not get spaceID and nodeID from cache")
|
||||
} else {
|
||||
err := c.kv.Purge(ctx, baseKey)
|
||||
if err != nil && err != nats.ErrKeyNotFound {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("record", path).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache")
|
||||
}
|
||||
|
||||
err = c.kv.Purge(ctx, cacheKey(spaceID, nodeID))
|
||||
if err != nil && err != nats.ErrKeyNotFound {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("record", path).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache")
|
||||
}
|
||||
}
|
||||
|
||||
watcher, err := c.kv.Watch(ctx, baseKey+".*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = watcher.Stop() }()
|
||||
|
||||
for update := range watcher.Updates() {
|
||||
if update == nil {
|
||||
break
|
||||
}
|
||||
key := update.Key()
|
||||
|
||||
spaceID, nodeID, ok := c.getByReverseCacheKey(ctx, key)
|
||||
if !ok {
|
||||
appctx.GetLogger(ctx).Error().Str("record", key).Msg("could not get spaceID and nodeID from cache")
|
||||
continue
|
||||
}
|
||||
|
||||
err := c.kv.Purge(ctx, key)
|
||||
if err != nil && err != nats.ErrKeyNotFound {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("record", key).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache")
|
||||
}
|
||||
|
||||
err = c.kv.Purge(ctx, cacheKey(spaceID, nodeID))
|
||||
if err != nil && err != nats.ErrKeyNotFound {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("record", key).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeletePath removes only the path entry from the cache
|
||||
func (c *IDCache) DeletePath(ctx context.Context, path string) error {
|
||||
return c.kv.Purge(ctx, reverseCacheKey(path))
|
||||
}
|
||||
|
||||
// Set adds a new entry to the cache
|
||||
func (c *IDCache) Set(ctx context.Context, spaceID, nodeID, val string) error {
|
||||
_, err := c.kv.Put(ctx, cacheKey(spaceID, nodeID), []byte(val))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = c.kv.Put(ctx, reverseCacheKey(val), []byte(cacheKey(spaceID, nodeID)))
|
||||
return err
|
||||
}
|
||||
|
||||
// Get returns the value for a given key
|
||||
func (c *IDCache) Get(ctx context.Context, spaceID, nodeID string) (string, bool) {
|
||||
record, err := c.kv.Get(ctx, cacheKey(spaceID, nodeID))
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
return string(record.Value()), true
|
||||
}
|
||||
|
||||
func (c *IDCache) getByReverseCacheKey(ctx context.Context, reverseKey string) (string, string, bool) {
|
||||
record, err := c.kv.Get(ctx, reverseKey)
|
||||
if err != nil {
|
||||
return "", "", false
|
||||
}
|
||||
decoded, err := base32.StdEncoding.DecodeString(string(record.Value()))
|
||||
if err != nil {
|
||||
return "", "", false
|
||||
}
|
||||
parts := strings.SplitN(string(decoded), "!", 2)
|
||||
if len(parts) != 2 {
|
||||
return "", "", false
|
||||
}
|
||||
return parts[0], parts[1], true
|
||||
}
|
||||
|
||||
// GetByPath returns the key for a given value
|
||||
func (c *IDCache) GetByPath(ctx context.Context, path string) (string, string, bool) {
|
||||
return c.getByReverseCacheKey(ctx, reverseCacheKey(path))
|
||||
}
|
||||
|
||||
func cacheKey(spaceid, nodeID string) string {
|
||||
return base32.StdEncoding.EncodeToString([]byte(spaceid + "!" + nodeID))
|
||||
}
|
||||
|
||||
func reverseCacheKey(path string) string {
|
||||
parts := strings.Split(strings.TrimPrefix(path, string(filepath.Separator)), string(filepath.Separator))
|
||||
encoded := make([]string, len(parts))
|
||||
for i, p := range parts {
|
||||
encoded[i] = base32.StdEncoding.EncodeToString([]byte(p))
|
||||
}
|
||||
|
||||
return strings.Join(encoded, ".")
|
||||
}
|
||||
+5
-9
@@ -25,7 +25,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
@@ -33,6 +32,7 @@ import (
|
||||
lru "github.com/hashicorp/golang-lru/v2"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/appctx"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/errtypes"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/idcache"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/options"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/metadata"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/metadata/prefixes"
|
||||
@@ -82,24 +82,20 @@ type Lookup struct {
|
||||
}
|
||||
|
||||
// New returns a new Lookup instance
|
||||
func New(b metadata.Backend, um usermapper.Mapper, o *options.Options, tm node.TimeManager) *Lookup {
|
||||
idHistoryConf := o.IDCache
|
||||
idHistoryConf.Table = o.IDCache.Table + "_history"
|
||||
idHistoryConf.TTL = 1 * time.Minute
|
||||
|
||||
func New(b metadata.Backend, um usermapper.Mapper, o *options.Options, tm node.TimeManager, cache, historyCache *idcache.IDCache) (*Lookup, error) {
|
||||
spaceRootCache, _ := lru.New[string, string](1000)
|
||||
|
||||
lu := &Lookup{
|
||||
Options: o,
|
||||
metadataBackend: b,
|
||||
IDCache: NewStoreIDCache(o.IDCache),
|
||||
IDHistoryCache: NewStoreIDCache(idHistoryConf),
|
||||
IDCache: cache,
|
||||
IDHistoryCache: historyCache,
|
||||
spaceRootCache: spaceRootCache,
|
||||
userMapper: um,
|
||||
tm: tm,
|
||||
}
|
||||
|
||||
return lu
|
||||
return lu, nil
|
||||
}
|
||||
|
||||
// CacheID caches the path for the given space and node id
|
||||
|
||||
Generated
Vendored
-162
@@ -1,162 +0,0 @@
|
||||
// Copyright 2018-2021 CERN
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// In applying this license, CERN does not waive the privileges and immunities
|
||||
// granted to it by virtue of its status as an Intergovernmental Organization
|
||||
// or submit itself to any jurisdiction.
|
||||
|
||||
package lookup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
microstore "go-micro.dev/v4/store"
|
||||
|
||||
"github.com/opencloud-eu/reva/v2/pkg/appctx"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/cache"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/store"
|
||||
)
|
||||
|
||||
type StoreIDCache struct {
|
||||
cache microstore.Store
|
||||
}
|
||||
|
||||
// NewMemoryIDCache returns a new MemoryIDCache
|
||||
func NewStoreIDCache(c cache.Config) *StoreIDCache {
|
||||
return &StoreIDCache{
|
||||
cache: store.Create(
|
||||
store.Store(c.Store),
|
||||
store.TTL(c.TTL),
|
||||
store.Size(c.Size),
|
||||
microstore.Nodes(c.Nodes...),
|
||||
microstore.Database(c.Database),
|
||||
microstore.Table(c.Table),
|
||||
store.DisablePersistence(c.DisablePersistence),
|
||||
store.Authentication(c.AuthUsername, c.AuthPassword),
|
||||
store.TLSEnabled(c.TLSEnabled),
|
||||
store.TLSInsecure(c.TLSInsecure),
|
||||
store.TLSRootCA(c.TLSRootCACertificate),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Delete removes an entry from the cache
|
||||
func (c *StoreIDCache) Delete(_ context.Context, spaceID, nodeID string) error {
|
||||
var rerr error
|
||||
v, err := c.cache.Read(cacheKey(spaceID, nodeID))
|
||||
if err == nil {
|
||||
rerr = c.cache.Delete(reverseCacheKey(string(v[0].Value)))
|
||||
}
|
||||
|
||||
err = c.cache.Delete(cacheKey(spaceID, nodeID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return rerr
|
||||
}
|
||||
|
||||
// DeleteByPath removes an entry from the cache
|
||||
func (c *StoreIDCache) DeleteByPath(ctx context.Context, path string) error {
|
||||
spaceID, nodeID, ok := c.GetByPath(ctx, path)
|
||||
if !ok {
|
||||
appctx.GetLogger(ctx).Error().Str("record", path).Msg("could not get spaceID and nodeID from cache")
|
||||
} else {
|
||||
err := c.cache.Delete(reverseCacheKey(path))
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("record", path).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache")
|
||||
}
|
||||
|
||||
err = c.cache.Delete(cacheKey(spaceID, nodeID))
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("record", path).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache")
|
||||
}
|
||||
}
|
||||
|
||||
list, err := c.cache.List(
|
||||
microstore.ListPrefix(reverseCacheKey(path) + "/"),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, record := range list {
|
||||
spaceID, nodeID, ok := c.GetByPath(ctx, record)
|
||||
if !ok {
|
||||
appctx.GetLogger(ctx).Error().Str("record", record).Msg("could not get spaceID and nodeID from cache")
|
||||
continue
|
||||
}
|
||||
|
||||
err := c.cache.Delete(reverseCacheKey(record))
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("record", record).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache")
|
||||
}
|
||||
|
||||
err = c.cache.Delete(cacheKey(spaceID, nodeID))
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("record", record).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeletePath removes only the path entry from the cache
|
||||
func (c *StoreIDCache) DeletePath(ctx context.Context, path string) error {
|
||||
return c.cache.Delete(reverseCacheKey(path))
|
||||
}
|
||||
|
||||
// Add adds a new entry to the cache
|
||||
func (c *StoreIDCache) Set(_ context.Context, spaceID, nodeID, val string) error {
|
||||
err := c.cache.Write(µstore.Record{
|
||||
Key: cacheKey(spaceID, nodeID),
|
||||
Value: []byte(val),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.cache.Write(µstore.Record{
|
||||
Key: reverseCacheKey(val),
|
||||
Value: []byte(cacheKey(spaceID, nodeID)),
|
||||
})
|
||||
}
|
||||
|
||||
// Get returns the value for a given key
|
||||
func (c *StoreIDCache) Get(_ context.Context, spaceID, nodeID string) (string, bool) {
|
||||
records, err := c.cache.Read(cacheKey(spaceID, nodeID))
|
||||
if err != nil || len(records) == 0 {
|
||||
return "", false
|
||||
}
|
||||
return string(records[0].Value), true
|
||||
}
|
||||
|
||||
// GetByPath returns the key for a given value
|
||||
func (c *StoreIDCache) GetByPath(_ context.Context, val string) (string, string, bool) {
|
||||
records, err := c.cache.Read(reverseCacheKey(val))
|
||||
if err != nil || len(records) == 0 {
|
||||
return "", "", false
|
||||
}
|
||||
parts := strings.SplitN(string(records[0].Value), "!", 2)
|
||||
if len(parts) != 2 {
|
||||
return "", "", false
|
||||
}
|
||||
return parts[0], parts[1], true
|
||||
}
|
||||
|
||||
func cacheKey(spaceid, nodeID string) string {
|
||||
return spaceid + "!" + nodeID
|
||||
}
|
||||
|
||||
func reverseCacheKey(val string) string {
|
||||
return val
|
||||
}
|
||||
+43
-26
@@ -27,12 +27,13 @@ import (
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
tusd "github.com/tus/tusd/v2/pkg/handler"
|
||||
microstore "go-micro.dev/v4/store"
|
||||
|
||||
"github.com/opencloud-eu/reva/v2/pkg/events"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/cache"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/blobstore"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/idcache"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/lookup"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/options"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/timemanager"
|
||||
@@ -47,12 +48,11 @@ import (
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/upload"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/usermapper"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/utils/middleware"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/store"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("posix", New)
|
||||
registry.Register("posix", NewDefault)
|
||||
}
|
||||
|
||||
type posixFS struct {
|
||||
@@ -63,12 +63,41 @@ type posixFS struct {
|
||||
|
||||
// New returns an implementation to of the storage.FS interface that talk to
|
||||
// a local filesystem.
|
||||
func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (storage.FS, error) {
|
||||
func NewDefault(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (storage.FS, error) {
|
||||
o, err := options.New(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
o.IDCache.Database += "_v2" // Use a versioned bucket name to avoid conflicts with previous implementations
|
||||
kv, err := cache.NewNatsKeyValue(o.IDCache)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not create nats key value store")
|
||||
}
|
||||
c, err := idcache.NewStoreIDCache(kv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
o.IDCache.Database += "_history" // Use a versioned bucket name to avoid conflicts with previous implementations
|
||||
historyKv, err := cache.NewNatsKeyValue(o.IDCache)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not create nats key value store")
|
||||
}
|
||||
historyCache, err := idcache.NewStoreIDCache(historyKv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return New(o, stream, c, historyCache, log)
|
||||
}
|
||||
|
||||
func New(o *options.Options, stream events.Stream, cache, historyCache *idcache.IDCache, log *zerolog.Logger) (storage.FS, error) {
|
||||
if o.IDCache.Store != "nats-js-kv" {
|
||||
return nil, fmt.Errorf("the posix driver requires a nats-js-kv cache")
|
||||
}
|
||||
|
||||
var err error
|
||||
if log == nil {
|
||||
log = &zerolog.Logger{}
|
||||
}
|
||||
@@ -89,9 +118,12 @@ func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (s
|
||||
var lu *lookup.Lookup
|
||||
switch o.MetadataBackend {
|
||||
case "xattrs":
|
||||
lu = lookup.New(metadata.NewXattrsBackend(o.FileMetadataCache), um, o, &timemanager.Manager{})
|
||||
lu, err = lookup.New(metadata.NewXattrsBackend(o.FileMetadataCache), um, o, &timemanager.Manager{}, cache, historyCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "hybrid":
|
||||
lu = lookup.New(metadata.NewHybridBackend(1024, // start offloading grants after 1KB
|
||||
lu, err = lookup.New(metadata.NewHybridBackend(1024, // start offloading grants after 1KB
|
||||
func(n metadata.MetadataNode) string {
|
||||
spaceRoot, _ := lu.IDCache.Get(context.Background(), n.GetSpaceID(), n.GetSpaceID())
|
||||
if len(spaceRoot) == 0 {
|
||||
@@ -100,7 +132,10 @@ func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (s
|
||||
|
||||
return filepath.Join(spaceRoot, lookup.MetadataDir)
|
||||
},
|
||||
o.FileMetadataCache), um, o, &timemanager.Manager{})
|
||||
o.FileMetadataCache), um, o, &timemanager.Manager{}, cache, historyCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown metadata backend %s, only 'xattrs' or 'hybrid' (default) supported", o.MetadataBackend)
|
||||
}
|
||||
@@ -125,25 +160,7 @@ func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (s
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch o.IDCache.Store {
|
||||
case "", "memory", "noop":
|
||||
return nil, fmt.Errorf("the posix driver requires a shared id cache, e.g. nats-js-kv or redis")
|
||||
}
|
||||
|
||||
tp, err := tree.New(lu, bs, um, trashbin, p, o, stream, store.Create(
|
||||
// TODO use a NewStoreIDCache here?
|
||||
store.Store(o.IDCache.Store),
|
||||
store.TTL(o.IDCache.TTL),
|
||||
store.Size(o.IDCache.Size),
|
||||
microstore.Nodes(o.IDCache.Nodes...),
|
||||
microstore.Database(o.IDCache.Database),
|
||||
microstore.Table(o.IDCache.Table),
|
||||
store.DisablePersistence(o.IDCache.DisablePersistence),
|
||||
store.Authentication(o.IDCache.AuthUsername, o.IDCache.AuthPassword),
|
||||
store.TLSEnabled(o.IDCache.TLSEnabled),
|
||||
store.TLSInsecure(o.IDCache.TLSInsecure),
|
||||
store.TLSRootCA(o.IDCache.TLSRootCACertificate),
|
||||
), log)
|
||||
tp, err := tree.New(lu, bs, um, trashbin, p, o, stream, cache, log)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+8
-8
@@ -33,7 +33,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pkg/xattr"
|
||||
"github.com/rs/zerolog"
|
||||
"go-micro.dev/v4/store"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@@ -45,6 +44,7 @@ import (
|
||||
"github.com/opencloud-eu/reva/v2/pkg/errtypes"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/events"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/blobstore"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/idcache"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/lookup"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/options"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/trashbin"
|
||||
@@ -93,7 +93,7 @@ type Tree struct {
|
||||
projectSpacesRoot string
|
||||
|
||||
userMapper usermapper.Mapper
|
||||
idCache store.Store
|
||||
idCache *idcache.IDCache
|
||||
watcher Watcher
|
||||
scanQueue chan scanItem
|
||||
scanDebouncer *ScanDebouncer
|
||||
@@ -106,7 +106,7 @@ type Tree struct {
|
||||
type PermissionCheckFunc func(rp *provider.ResourcePermissions) bool
|
||||
|
||||
// New returns a new instance of Tree
|
||||
func New(lu node.PathLookup, bs node.Blobstore, um usermapper.Mapper, trashbin *trashbin.Trashbin, permissions permissions.Permissions, o *options.Options, es events.Stream, cache store.Store, log *zerolog.Logger) (*Tree, error) {
|
||||
func New(lu node.PathLookup, bs node.Blobstore, um usermapper.Mapper, trashbin *trashbin.Trashbin, permissions permissions.Permissions, o *options.Options, es events.Stream, cache *idcache.IDCache, log *zerolog.Logger) (*Tree, error) {
|
||||
scanQueue := make(chan scanItem)
|
||||
|
||||
t := &Tree{
|
||||
@@ -585,7 +585,7 @@ func (t *Tree) Delete(ctx context.Context, n *node.Node) error {
|
||||
|
||||
// remove entry from cache immediately to avoid inconsistencies
|
||||
defer func() {
|
||||
if err := t.idCache.Delete(path); err != nil {
|
||||
if err := t.idCache.DeleteByPath(ctx, path); err != nil {
|
||||
t.log.Error().Err(err).Str("path", path).Msg("could not delete id from cache")
|
||||
}
|
||||
}()
|
||||
@@ -820,10 +820,10 @@ func isTrash(path string) bool {
|
||||
return strings.HasSuffix(path, ".trashinfo") || strings.HasSuffix(path, ".trashitem") || strings.Contains(path, ".Trash")
|
||||
}
|
||||
|
||||
func (t *Tree) AddFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
func (t *Tree) AddLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
func (t *Tree) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
func (t *Tree) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
Generated
Vendored
+14
-6
@@ -1035,9 +1035,13 @@ func (fs *Decomposedfs) ListFolder(ctx context.Context, ref *provider.Reference,
|
||||
return finfos, nil
|
||||
}
|
||||
|
||||
// AddFavorite adds a favorite
|
||||
func (fs *Decomposedfs) AddFavorite(ctx context.Context, ref *provider.Reference, uid *user.UserId) error {
|
||||
ctx, span := tracer.Start(ctx, "AddFavorite")
|
||||
// AddLabel adds a favorite
|
||||
func (fs *Decomposedfs) AddLabel(ctx context.Context, ref *provider.Reference, uid *user.UserId, label string) error {
|
||||
if label != "favorite" {
|
||||
return errtypes.BadRequest("unsupported label: " + label)
|
||||
}
|
||||
|
||||
ctx, span := tracer.Start(ctx, "AddLabel")
|
||||
defer span.End()
|
||||
n, err := fs.lu.NodeFromResource(ctx, ref)
|
||||
if err != nil {
|
||||
@@ -1058,9 +1062,13 @@ func (fs *Decomposedfs) AddFavorite(ctx context.Context, ref *provider.Reference
|
||||
return n.SetFavorite(ctx, uid)
|
||||
}
|
||||
|
||||
// RemoveFavorite removes a favorite
|
||||
func (fs *Decomposedfs) RemoveFavorite(ctx context.Context, ref *provider.Reference, uid *user.UserId) error {
|
||||
ctx, span := tracer.Start(ctx, "RemoveFavorite")
|
||||
// RemoveLabel removes a favorite
|
||||
func (fs *Decomposedfs) RemoveLabel(ctx context.Context, ref *provider.Reference, uid *user.UserId, label string) error {
|
||||
if label != "favorite" {
|
||||
return errtypes.BadRequest("unsupported label: " + label)
|
||||
}
|
||||
|
||||
ctx, span := tracer.Start(ctx, "RemoveLabel")
|
||||
defer span.End()
|
||||
n, err := fs.lu.NodeFromResource(ctx, ref)
|
||||
if err != nil {
|
||||
|
||||
+4
-4
@@ -117,10 +117,10 @@ type FS interface {
|
||||
// UnsetArbitraryMetadata removes arbitraty metadata from a resource
|
||||
UnsetArbitraryMetadata(ctx context.Context, ref *provider.Reference, keys []string) error
|
||||
|
||||
// AddFavorite adds a favorite to a resource
|
||||
AddFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error
|
||||
// RemoveFavorite removes a favorite from a resource
|
||||
RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error
|
||||
// AddLabel adds a label to a resource
|
||||
AddLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error
|
||||
// RemoveLabel removes a label from a resource
|
||||
RemoveLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error
|
||||
|
||||
// Locks
|
||||
|
||||
|
||||
Generated
Vendored
+4
-4
@@ -1233,12 +1233,12 @@ func (fs *Decomposedfs) Unlock(ctx context.Context, ref *provider.Reference, loc
|
||||
return node.Unlock(ctx, lock)
|
||||
}
|
||||
|
||||
func (fs *Decomposedfs) AddFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
func (fs *Decomposedfs) AddLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
func (fs *Decomposedfs) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *user.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
func (fs *Decomposedfs) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *user.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
func (fs *Decomposedfs) ListRecycle(ctx context.Context, ref *provider.Reference, key, relativePath string) ([]*provider.RecycleItem, error) {
|
||||
|
||||
+4
-4
@@ -281,12 +281,12 @@ func (fs *eosfs) Shutdown(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fs *eosfs) AddFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
func (fs *eosfs) AddLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
func (fs *eosfs) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
func (fs *eosfs) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
func getUser(ctx context.Context) (*userpb.User, error) {
|
||||
|
||||
+4
-4
@@ -722,12 +722,12 @@ func (fs *localfs) GetLock(ctx context.Context, ref *provider.Reference) (*provi
|
||||
return nil, errtypes.NotSupported("unimplemented")
|
||||
}
|
||||
|
||||
func (fs *localfs) AddFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
return errtypes.NotSupported("AddFavorite not implemented")
|
||||
func (fs *localfs) AddLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
return errtypes.NotSupported("AddLabel not implemented")
|
||||
}
|
||||
|
||||
func (fs *localfs) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
return errtypes.NotSupported("RemoveFavorite not implemented")
|
||||
func (fs *localfs) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
return errtypes.NotSupported("RemoveLabel not implemented")
|
||||
}
|
||||
|
||||
// SetLock puts a lock on the given reference
|
||||
|
||||
Generated
Vendored
+6
-6
@@ -1090,14 +1090,14 @@ func (f *FS) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorage
|
||||
return res0
|
||||
}
|
||||
|
||||
func (f *FS) AddFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
func (f *FS) AddLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
var (
|
||||
err error
|
||||
unhook UnHook
|
||||
unhooks []UnHook
|
||||
)
|
||||
for _, hook := range f.hooks {
|
||||
ctx, unhook, err = hook("AddFavorite", ctx, ref.GetResourceId().GetSpaceId())
|
||||
ctx, unhook, err = hook("AddLabel", ctx, ref.GetResourceId().GetSpaceId())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1106,7 +1106,7 @@ func (f *FS) AddFavorite(ctx context.Context, ref *provider.Reference, userID *u
|
||||
}
|
||||
}
|
||||
|
||||
res0 := f.next.AddFavorite(ctx, ref, userID)
|
||||
res0 := f.next.AddLabel(ctx, ref, userID, label)
|
||||
|
||||
for _, unhook := range unhooks {
|
||||
if err := unhook(); err != nil {
|
||||
@@ -1117,14 +1117,14 @@ func (f *FS) AddFavorite(ctx context.Context, ref *provider.Reference, userID *u
|
||||
return res0
|
||||
}
|
||||
|
||||
func (f *FS) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID *userpb.UserId) error {
|
||||
func (f *FS) RemoveLabel(ctx context.Context, ref *provider.Reference, userID *userpb.UserId, label string) error {
|
||||
var (
|
||||
err error
|
||||
unhook UnHook
|
||||
unhooks []UnHook
|
||||
)
|
||||
for _, hook := range f.hooks {
|
||||
ctx, unhook, err = hook("RemoveFavorite", ctx, ref.GetResourceId().GetSpaceId())
|
||||
ctx, unhook, err = hook("RemoveLabel", ctx, ref.GetResourceId().GetSpaceId())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1133,7 +1133,7 @@ func (f *FS) RemoveFavorite(ctx context.Context, ref *provider.Reference, userID
|
||||
}
|
||||
}
|
||||
|
||||
res0 := f.next.RemoveFavorite(ctx, ref, userID)
|
||||
res0 := f.next.RemoveLabel(ctx, ref, userID, label)
|
||||
|
||||
for _, unhook := range unhooks {
|
||||
if err := unhook(); err != nil {
|
||||
|
||||
+36
-36
@@ -224,8 +224,8 @@ func (_c *GatewayAPIClient_AddAppProvider_Call) RunAndReturn(run func(context.Co
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddFavorite provides a mock function with given fields: ctx, in, opts
|
||||
func (_m *GatewayAPIClient) AddFavorite(ctx context.Context, in *providerv1beta1.AddFavoriteRequest, opts ...grpc.CallOption) (*providerv1beta1.AddFavoriteResponse, error) {
|
||||
// AddLabel provides a mock function with given fields: ctx, in, opts
|
||||
func (_m *GatewayAPIClient) AddLabel(ctx context.Context, in *providerv1beta1.AddLabelRequest, opts ...grpc.CallOption) (*providerv1beta1.AddLabelResponse, error) {
|
||||
var tmpRet mock.Arguments
|
||||
if len(opts) > 0 {
|
||||
tmpRet = _m.Called(ctx, in, opts)
|
||||
@@ -235,23 +235,23 @@ func (_m *GatewayAPIClient) AddFavorite(ctx context.Context, in *providerv1beta1
|
||||
ret := tmpRet
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AddFavorite")
|
||||
panic("no return value specified for AddLabel")
|
||||
}
|
||||
|
||||
var r0 *providerv1beta1.AddFavoriteResponse
|
||||
var r0 *providerv1beta1.AddLabelResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.AddFavoriteRequest, ...grpc.CallOption) (*providerv1beta1.AddFavoriteResponse, error)); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.AddLabelRequest, ...grpc.CallOption) (*providerv1beta1.AddLabelResponse, error)); ok {
|
||||
return rf(ctx, in, opts...)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.AddFavoriteRequest, ...grpc.CallOption) *providerv1beta1.AddFavoriteResponse); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.AddLabelRequest, ...grpc.CallOption) *providerv1beta1.AddLabelResponse); ok {
|
||||
r0 = rf(ctx, in, opts...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*providerv1beta1.AddFavoriteResponse)
|
||||
r0 = ret.Get(0).(*providerv1beta1.AddLabelResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.AddFavoriteRequest, ...grpc.CallOption) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.AddLabelRequest, ...grpc.CallOption) error); ok {
|
||||
r1 = rf(ctx, in, opts...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
@@ -260,21 +260,21 @@ func (_m *GatewayAPIClient) AddFavorite(ctx context.Context, in *providerv1beta1
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GatewayAPIClient_AddFavorite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFavorite'
|
||||
type GatewayAPIClient_AddFavorite_Call struct {
|
||||
// GatewayAPIClient_AddLabel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddLabel'
|
||||
type GatewayAPIClient_AddLabel_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AddFavorite is a helper method to define mock.On call
|
||||
// AddLabel is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in *providerv1beta1.AddFavoriteRequest
|
||||
// - in *providerv1beta1.AddLabelRequest
|
||||
// - opts ...grpc.CallOption
|
||||
func (_e *GatewayAPIClient_Expecter) AddFavorite(ctx interface{}, in interface{}, opts ...interface{}) *GatewayAPIClient_AddFavorite_Call {
|
||||
return &GatewayAPIClient_AddFavorite_Call{Call: _e.mock.On("AddFavorite",
|
||||
func (_e *GatewayAPIClient_Expecter) AddLabel(ctx interface{}, in interface{}, opts ...interface{}) *GatewayAPIClient_AddLabel_Call {
|
||||
return &GatewayAPIClient_AddLabel_Call{Call: _e.mock.On("AddLabel",
|
||||
append([]interface{}{ctx, in}, opts...)...)}
|
||||
}
|
||||
|
||||
func (_c *GatewayAPIClient_AddFavorite_Call) Run(run func(ctx context.Context, in *providerv1beta1.AddFavoriteRequest, opts ...grpc.CallOption)) *GatewayAPIClient_AddFavorite_Call {
|
||||
func (_c *GatewayAPIClient_AddLabel_Call) Run(run func(ctx context.Context, in *providerv1beta1.AddLabelRequest, opts ...grpc.CallOption)) *GatewayAPIClient_AddLabel_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]grpc.CallOption, len(args)-2)
|
||||
for i, a := range args[2:] {
|
||||
@@ -282,17 +282,17 @@ func (_c *GatewayAPIClient_AddFavorite_Call) Run(run func(ctx context.Context, i
|
||||
variadicArgs[i] = a.(grpc.CallOption)
|
||||
}
|
||||
}
|
||||
run(args[0].(context.Context), args[1].(*providerv1beta1.AddFavoriteRequest), variadicArgs...)
|
||||
run(args[0].(context.Context), args[1].(*providerv1beta1.AddLabelRequest), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GatewayAPIClient_AddFavorite_Call) Return(_a0 *providerv1beta1.AddFavoriteResponse, _a1 error) *GatewayAPIClient_AddFavorite_Call {
|
||||
func (_c *GatewayAPIClient_AddLabel_Call) Return(_a0 *providerv1beta1.AddLabelResponse, _a1 error) *GatewayAPIClient_AddLabel_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GatewayAPIClient_AddFavorite_Call) RunAndReturn(run func(context.Context, *providerv1beta1.AddFavoriteRequest, ...grpc.CallOption) (*providerv1beta1.AddFavoriteResponse, error)) *GatewayAPIClient_AddFavorite_Call {
|
||||
func (_c *GatewayAPIClient_AddLabel_Call) RunAndReturn(run func(context.Context, *providerv1beta1.AddLabelRequest, ...grpc.CallOption) (*providerv1beta1.AddLabelResponse, error)) *GatewayAPIClient_AddLabel_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
@@ -6210,8 +6210,8 @@ func (_c *GatewayAPIClient_RefreshLock_Call) RunAndReturn(run func(context.Conte
|
||||
return _c
|
||||
}
|
||||
|
||||
// RemoveFavorite provides a mock function with given fields: ctx, in, opts
|
||||
func (_m *GatewayAPIClient) RemoveFavorite(ctx context.Context, in *providerv1beta1.RemoveFavoriteRequest, opts ...grpc.CallOption) (*providerv1beta1.RemoveFavoriteResponse, error) {
|
||||
// RemoveLabel provides a mock function with given fields: ctx, in, opts
|
||||
func (_m *GatewayAPIClient) RemoveLabel(ctx context.Context, in *providerv1beta1.RemoveLabelRequest, opts ...grpc.CallOption) (*providerv1beta1.RemoveLabelResponse, error) {
|
||||
var tmpRet mock.Arguments
|
||||
if len(opts) > 0 {
|
||||
tmpRet = _m.Called(ctx, in, opts)
|
||||
@@ -6221,23 +6221,23 @@ func (_m *GatewayAPIClient) RemoveFavorite(ctx context.Context, in *providerv1be
|
||||
ret := tmpRet
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for RemoveFavorite")
|
||||
panic("no return value specified for RemoveLabel")
|
||||
}
|
||||
|
||||
var r0 *providerv1beta1.RemoveFavoriteResponse
|
||||
var r0 *providerv1beta1.RemoveLabelResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.RemoveFavoriteRequest, ...grpc.CallOption) (*providerv1beta1.RemoveFavoriteResponse, error)); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.RemoveLabelRequest, ...grpc.CallOption) (*providerv1beta1.RemoveLabelResponse, error)); ok {
|
||||
return rf(ctx, in, opts...)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.RemoveFavoriteRequest, ...grpc.CallOption) *providerv1beta1.RemoveFavoriteResponse); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.RemoveLabelRequest, ...grpc.CallOption) *providerv1beta1.RemoveLabelResponse); ok {
|
||||
r0 = rf(ctx, in, opts...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*providerv1beta1.RemoveFavoriteResponse)
|
||||
r0 = ret.Get(0).(*providerv1beta1.RemoveLabelResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.RemoveFavoriteRequest, ...grpc.CallOption) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.RemoveLabelRequest, ...grpc.CallOption) error); ok {
|
||||
r1 = rf(ctx, in, opts...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
@@ -6246,21 +6246,21 @@ func (_m *GatewayAPIClient) RemoveFavorite(ctx context.Context, in *providerv1be
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GatewayAPIClient_RemoveFavorite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveFavorite'
|
||||
type GatewayAPIClient_RemoveFavorite_Call struct {
|
||||
// GatewayAPIClient_RemoveLabel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveLabel'
|
||||
type GatewayAPIClient_RemoveLabel_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// RemoveFavorite is a helper method to define mock.On call
|
||||
// RemoveLabel is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in *providerv1beta1.RemoveFavoriteRequest
|
||||
// - in *providerv1beta1.RemoveLabelRequest
|
||||
// - opts ...grpc.CallOption
|
||||
func (_e *GatewayAPIClient_Expecter) RemoveFavorite(ctx interface{}, in interface{}, opts ...interface{}) *GatewayAPIClient_RemoveFavorite_Call {
|
||||
return &GatewayAPIClient_RemoveFavorite_Call{Call: _e.mock.On("RemoveFavorite",
|
||||
func (_e *GatewayAPIClient_Expecter) RemoveLabel(ctx interface{}, in interface{}, opts ...interface{}) *GatewayAPIClient_RemoveLabel_Call {
|
||||
return &GatewayAPIClient_RemoveLabel_Call{Call: _e.mock.On("RemoveLabel",
|
||||
append([]interface{}{ctx, in}, opts...)...)}
|
||||
}
|
||||
|
||||
func (_c *GatewayAPIClient_RemoveFavorite_Call) Run(run func(ctx context.Context, in *providerv1beta1.RemoveFavoriteRequest, opts ...grpc.CallOption)) *GatewayAPIClient_RemoveFavorite_Call {
|
||||
func (_c *GatewayAPIClient_RemoveLabel_Call) Run(run func(ctx context.Context, in *providerv1beta1.RemoveLabelRequest, opts ...grpc.CallOption)) *GatewayAPIClient_RemoveLabel_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]grpc.CallOption, len(args)-2)
|
||||
for i, a := range args[2:] {
|
||||
@@ -6268,17 +6268,17 @@ func (_c *GatewayAPIClient_RemoveFavorite_Call) Run(run func(ctx context.Context
|
||||
variadicArgs[i] = a.(grpc.CallOption)
|
||||
}
|
||||
}
|
||||
run(args[0].(context.Context), args[1].(*providerv1beta1.RemoveFavoriteRequest), variadicArgs...)
|
||||
run(args[0].(context.Context), args[1].(*providerv1beta1.RemoveLabelRequest), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GatewayAPIClient_RemoveFavorite_Call) Return(_a0 *providerv1beta1.RemoveFavoriteResponse, _a1 error) *GatewayAPIClient_RemoveFavorite_Call {
|
||||
func (_c *GatewayAPIClient_RemoveLabel_Call) Return(_a0 *providerv1beta1.RemoveLabelResponse, _a1 error) *GatewayAPIClient_RemoveLabel_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GatewayAPIClient_RemoveFavorite_Call) RunAndReturn(run func(context.Context, *providerv1beta1.RemoveFavoriteRequest, ...grpc.CallOption) (*providerv1beta1.RemoveFavoriteResponse, error)) *GatewayAPIClient_RemoveFavorite_Call {
|
||||
func (_c *GatewayAPIClient_RemoveLabel_Call) RunAndReturn(run func(context.Context, *providerv1beta1.RemoveLabelRequest, ...grpc.CallOption) (*providerv1beta1.RemoveLabelResponse, error)) *GatewayAPIClient_RemoveLabel_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user