Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1716546989 |
No files matched your search
@@ -4,4 +4,4 @@ bumped reva version
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12051
|
||||
https://github.com/owncloud/ocis/pull/12087
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12132
|
||||
@@ -64,7 +64,7 @@ require (
|
||||
github.com/open-policy-agent/opa v1.12.3
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260304131727-ce3149532498
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260323165509-10be73721fb2
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.12
|
||||
github.com/prometheus/client_golang v1.23.2
|
||||
|
||||
@@ -742,8 +742,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
|
||||
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260304131727-ce3149532498 h1:ozyudPff1XLWSeTDW4ajT1tCoSQf18cFQRxtLWFCNbk=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260304131727-ce3149532498/go.mod h1:+rCy6oGYb2/qs5gmQa8y/pHARw634vB73MZGDY2SBIQ=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260323165509-10be73721fb2 h1:hNZ9oSuyLFiN1tZ9dQeaod7B70/zs3pgZyfTzf7gBOI=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260323165509-10be73721fb2/go.mod h1:+rCy6oGYb2/qs5gmQa8y/pHARw634vB73MZGDY2SBIQ=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pablodz/inotifywaitgo v0.0.9 h1:njquRbBU7fuwIe5rEvtaniVBjwWzcpdUVptSgzFqZsw=
|
||||
|
||||
+15
-27
@@ -24,13 +24,13 @@ import (
|
||||
"strings"
|
||||
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/owncloud/reva/v2/pkg/errtypes"
|
||||
"github.com/owncloud/reva/v2/pkg/rgrpc"
|
||||
"github.com/owncloud/reva/v2/pkg/sharedconf"
|
||||
"github.com/owncloud/reva/v2/pkg/storage/cache"
|
||||
"github.com/owncloud/reva/v2/pkg/token"
|
||||
"github.com/owncloud/reva/v2/pkg/token/manager/registry"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog"
|
||||
"google.golang.org/grpc"
|
||||
@@ -70,13 +70,12 @@ type config struct {
|
||||
TokenManager string `mapstructure:"token_manager"`
|
||||
// ShareFolder is the location where to create shares in the recipient's storage provider.
|
||||
// FIXME get rid of ShareFolder, there are findByPath calls in the ocmshareporvider.go and usershareprovider.go
|
||||
ShareFolder string `mapstructure:"share_folder"`
|
||||
DataTransfersFolder string `mapstructure:"data_transfers_folder"`
|
||||
TokenManagers map[string]map[string]interface{} `mapstructure:"token_managers"`
|
||||
AllowedUserAgents map[string][]string `mapstructure:"allowed_user_agents"` // map[path][]user-agent
|
||||
CreatePersonalSpaceCacheConfig cache.Config `mapstructure:"create_personal_space_cache_config"`
|
||||
ProviderCacheConfig cache.Config `mapstructure:"provider_cache_config"`
|
||||
UseCommonSpaceRootShareLogic bool `mapstructure:"use_common_space_root_share_logic"`
|
||||
ShareFolder string `mapstructure:"share_folder"`
|
||||
DataTransfersFolder string `mapstructure:"data_transfers_folder"`
|
||||
TokenManagers map[string]map[string]interface{} `mapstructure:"token_managers"`
|
||||
AllowedUserAgents map[string][]string `mapstructure:"allowed_user_agents"` // map[path][]user-agent
|
||||
ProviderCacheConfig cache.Config `mapstructure:"provider_cache_config"`
|
||||
UseCommonSpaceRootShareLogic bool `mapstructure:"use_common_space_root_share_logic"`
|
||||
}
|
||||
|
||||
// sets defaults
|
||||
@@ -130,22 +129,13 @@ func (c *config) init() {
|
||||
if c.ProviderCacheConfig.Database == "" {
|
||||
c.ProviderCacheConfig.Database = "reva"
|
||||
}
|
||||
|
||||
if c.CreatePersonalSpaceCacheConfig.Store == "" {
|
||||
c.CreatePersonalSpaceCacheConfig.Store = "memory"
|
||||
}
|
||||
|
||||
if c.CreatePersonalSpaceCacheConfig.Database == "" {
|
||||
c.CreatePersonalSpaceCacheConfig.Database = "reva"
|
||||
}
|
||||
}
|
||||
|
||||
type svc struct {
|
||||
c *config
|
||||
dataGatewayURL url.URL
|
||||
tokenmgr token.Manager
|
||||
providerCache cache.ProviderCache
|
||||
createPersonalSpaceCache cache.CreatePersonalSpaceCache
|
||||
c *config
|
||||
dataGatewayURL url.URL
|
||||
tokenmgr token.Manager
|
||||
providerCache cache.ProviderCache
|
||||
}
|
||||
|
||||
// New creates a new gateway svc that acts as a proxy for any grpc operation.
|
||||
@@ -171,11 +161,10 @@ func New(m map[string]interface{}, _ *grpc.Server, _ *zerolog.Logger) (rgrpc.Ser
|
||||
}
|
||||
|
||||
s := &svc{
|
||||
c: c,
|
||||
dataGatewayURL: *u,
|
||||
tokenmgr: tokenManager,
|
||||
providerCache: cache.GetProviderCache(c.ProviderCacheConfig),
|
||||
createPersonalSpaceCache: cache.GetCreatePersonalSpaceCache(c.CreatePersonalSpaceCacheConfig),
|
||||
c: c,
|
||||
dataGatewayURL: *u,
|
||||
tokenmgr: tokenManager,
|
||||
providerCache: cache.GetProviderCache(c.ProviderCacheConfig),
|
||||
}
|
||||
|
||||
return s, nil
|
||||
@@ -187,7 +176,6 @@ func (s *svc) Register(ss *grpc.Server) {
|
||||
|
||||
func (s *svc) Close() error {
|
||||
s.providerCache.Close()
|
||||
s.createPersonalSpaceCache.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Generated
Vendored
+4
-28
@@ -38,6 +38,7 @@ import (
|
||||
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/owncloud/reva/v2/pkg/appctx"
|
||||
ctxpkg "github.com/owncloud/reva/v2/pkg/ctx"
|
||||
"github.com/owncloud/reva/v2/pkg/errtypes"
|
||||
@@ -48,7 +49,6 @@ import (
|
||||
"github.com/owncloud/reva/v2/pkg/share"
|
||||
"github.com/owncloud/reva/v2/pkg/storagespace"
|
||||
"github.com/owncloud/reva/v2/pkg/utils"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/pkg/errors"
|
||||
gstatus "google.golang.org/grpc/status"
|
||||
)
|
||||
@@ -213,7 +213,7 @@ func (s *svc) CreateStorageSpace(ctx context.Context, req *provider.CreateStorag
|
||||
}
|
||||
|
||||
// just pick the first provider, we expect only one
|
||||
c, err := s.getSpacesProviderClient(ctx, res.Providers[0])
|
||||
c, err := pool.GetSpacesProviderServiceClient(res.Providers[0].Address)
|
||||
if err != nil {
|
||||
return &provider.CreateStorageSpaceResponse{
|
||||
Status: status.NewStatusFromErrType(ctx, "gateway could not get storage provider client", err),
|
||||
@@ -1027,7 +1027,7 @@ func (s *svc) find(ctx context.Context, ref *provider.Reference) (provider.Provi
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
client, err := s.getStorageProviderClient(ctx, p[0])
|
||||
client, err := pool.GetStorageProviderServiceClient(p[0].Address)
|
||||
return client, p[0], err
|
||||
}
|
||||
|
||||
@@ -1041,7 +1041,7 @@ func (s *svc) findSpacesProvider(ctx context.Context, ref *provider.Reference) (
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
client, err := s.getSpacesProviderClient(ctx, p[0])
|
||||
client, err := pool.GetSpacesProviderServiceClient(p[0].Address)
|
||||
return client, p[0], err
|
||||
}
|
||||
|
||||
@@ -1066,30 +1066,6 @@ func (s *svc) findAndUnwrap(ctx context.Context, ref *provider.Reference) (provi
|
||||
return c, p, relativeReference, nil
|
||||
}
|
||||
|
||||
func (s *svc) getSpacesProviderClient(_ context.Context, p *registry.ProviderInfo) (provider.SpacesAPIClient, error) {
|
||||
c, err := pool.GetSpacesProviderServiceClient(p.Address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &cachedSpacesAPIClient{
|
||||
c: c,
|
||||
createPersonalSpaceCache: s.createPersonalSpaceCache,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *svc) getStorageProviderClient(_ context.Context, p *registry.ProviderInfo) (provider.ProviderAPIClient, error) {
|
||||
c, err := pool.GetStorageProviderServiceClient(p.Address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &cachedAPIClient{
|
||||
c: c,
|
||||
createPersonalSpaceCache: s.createPersonalSpaceCache,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *svc) getStorageRegistryClient(_ context.Context, address string) (registry.RegistryAPIClient, error) {
|
||||
c, err := pool.GetStorageRegistryClient(address)
|
||||
if err != nil {
|
||||
|
||||
Generated
Vendored
-194
@@ -22,12 +22,10 @@ import (
|
||||
"context"
|
||||
|
||||
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
registry "github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1"
|
||||
ctxpkg "github.com/owncloud/reva/v2/pkg/ctx"
|
||||
sdk "github.com/owncloud/reva/v2/pkg/sdk/common"
|
||||
"github.com/owncloud/reva/v2/pkg/storage/cache"
|
||||
"github.com/owncloud/reva/v2/pkg/storagespace"
|
||||
"github.com/owncloud/reva/v2/pkg/utils"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc"
|
||||
@@ -83,195 +81,3 @@ func (c *cachedRegistryClient) GetStorageProviders(ctx context.Context, in *regi
|
||||
func (c *cachedRegistryClient) GetHome(ctx context.Context, in *registry.GetHomeRequest, opts ...grpc.CallOption) (*registry.GetHomeResponse, error) {
|
||||
return c.c.GetHome(ctx, in, opts...)
|
||||
}
|
||||
|
||||
/*
|
||||
Cached Spaces Provider
|
||||
*/
|
||||
|
||||
type cachedSpacesAPIClient struct {
|
||||
c provider.SpacesAPIClient
|
||||
createPersonalSpaceCache cache.CreatePersonalSpaceCache
|
||||
}
|
||||
|
||||
// CreateStorageSpace creates a storage space
|
||||
func (c *cachedSpacesAPIClient) CreateStorageSpace(ctx context.Context, in *provider.CreateStorageSpaceRequest, opts ...grpc.CallOption) (*provider.CreateStorageSpaceResponse, error) {
|
||||
if in.Type == "personal" {
|
||||
u, ok := ctxpkg.ContextGetUser(ctx)
|
||||
if !ok {
|
||||
return nil, errors.New("user not found in context")
|
||||
}
|
||||
|
||||
key := c.createPersonalSpaceCache.GetKey(u.GetId())
|
||||
if key != "" {
|
||||
s := &provider.CreateStorageSpaceResponse{}
|
||||
if err := c.createPersonalSpaceCache.PullFromCache(key, s); err == nil {
|
||||
return s, nil
|
||||
}
|
||||
}
|
||||
resp, err := c.c.CreateStorageSpace(ctx, in, opts...)
|
||||
switch {
|
||||
case err != nil:
|
||||
return nil, err
|
||||
case resp.Status.Code != rpc.Code_CODE_OK && resp.Status.Code != rpc.Code_CODE_ALREADY_EXISTS:
|
||||
return resp, nil
|
||||
case key == "":
|
||||
return resp, nil
|
||||
default:
|
||||
return resp, c.createPersonalSpaceCache.PushToCache(key, resp)
|
||||
}
|
||||
}
|
||||
return c.c.CreateStorageSpace(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (c *cachedSpacesAPIClient) ListStorageSpaces(ctx context.Context, in *provider.ListStorageSpacesRequest, opts ...grpc.CallOption) (*provider.ListStorageSpacesResponse, error) {
|
||||
return c.c.ListStorageSpaces(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedSpacesAPIClient) UpdateStorageSpace(ctx context.Context, in *provider.UpdateStorageSpaceRequest, opts ...grpc.CallOption) (*provider.UpdateStorageSpaceResponse, error) {
|
||||
return c.c.UpdateStorageSpace(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedSpacesAPIClient) DeleteStorageSpace(ctx context.Context, in *provider.DeleteStorageSpaceRequest, opts ...grpc.CallOption) (*provider.DeleteStorageSpaceResponse, error) {
|
||||
resp, err := c.c.DeleteStorageSpace(ctx, in, opts...)
|
||||
switch {
|
||||
case err != nil:
|
||||
return nil, err
|
||||
case resp.Status.Code != rpc.Code_CODE_OK:
|
||||
return resp, nil
|
||||
default:
|
||||
_, spaceid, _, _ := storagespace.SplitID(in.GetId().GetOpaqueId())
|
||||
_ = c.createPersonalSpaceCache.Delete(spaceid)
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Cached Storage Provider
|
||||
*/
|
||||
|
||||
type cachedAPIClient struct {
|
||||
c provider.ProviderAPIClient
|
||||
createPersonalSpaceCache cache.CreatePersonalSpaceCache
|
||||
}
|
||||
|
||||
// CreateHome caches calls to CreateHome locally - anyways they only need to be called once per user
|
||||
func (c *cachedAPIClient) CreateHome(ctx context.Context, in *provider.CreateHomeRequest, opts ...grpc.CallOption) (*provider.CreateHomeResponse, error) {
|
||||
u, ok := ctxpkg.ContextGetUser(ctx)
|
||||
if !ok {
|
||||
return nil, errors.New("user not found in context")
|
||||
}
|
||||
|
||||
key := c.createPersonalSpaceCache.GetKey(u.GetId())
|
||||
if key != "" {
|
||||
s := &provider.CreateHomeResponse{}
|
||||
if err := c.createPersonalSpaceCache.PullFromCache(key, s); err == nil {
|
||||
return s, nil
|
||||
}
|
||||
}
|
||||
resp, err := c.c.CreateHome(ctx, in, opts...)
|
||||
switch {
|
||||
case err != nil:
|
||||
return nil, err
|
||||
case resp.Status.Code != rpc.Code_CODE_OK && resp.Status.Code != rpc.Code_CODE_ALREADY_EXISTS:
|
||||
return resp, nil
|
||||
case key == "":
|
||||
return resp, nil
|
||||
default:
|
||||
return resp, c.createPersonalSpaceCache.PushToCache(key, resp)
|
||||
}
|
||||
}
|
||||
|
||||
// methods below here are not cached, they just call the client directly
|
||||
|
||||
// Stat returns the Resoure info for a given resource
|
||||
func (c *cachedAPIClient) Stat(ctx context.Context, in *provider.StatRequest, opts ...grpc.CallOption) (*provider.StatResponse, error) {
|
||||
return c.c.Stat(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) AddGrant(ctx context.Context, in *provider.AddGrantRequest, opts ...grpc.CallOption) (*provider.AddGrantResponse, error) {
|
||||
return c.c.AddGrant(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) CreateContainer(ctx context.Context, in *provider.CreateContainerRequest, opts ...grpc.CallOption) (*provider.CreateContainerResponse, error) {
|
||||
return c.c.CreateContainer(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) Delete(ctx context.Context, in *provider.DeleteRequest, opts ...grpc.CallOption) (*provider.DeleteResponse, error) {
|
||||
return c.c.Delete(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) DenyGrant(ctx context.Context, in *provider.DenyGrantRequest, opts ...grpc.CallOption) (*provider.DenyGrantResponse, error) {
|
||||
return c.c.DenyGrant(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) GetPath(ctx context.Context, in *provider.GetPathRequest, opts ...grpc.CallOption) (*provider.GetPathResponse, error) {
|
||||
return c.c.GetPath(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) GetQuota(ctx context.Context, in *provider.GetQuotaRequest, opts ...grpc.CallOption) (*provider.GetQuotaResponse, error) {
|
||||
return c.c.GetQuota(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) InitiateFileDownload(ctx context.Context, in *provider.InitiateFileDownloadRequest, opts ...grpc.CallOption) (*provider.InitiateFileDownloadResponse, error) {
|
||||
return c.c.InitiateFileDownload(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) InitiateFileUpload(ctx context.Context, in *provider.InitiateFileUploadRequest, opts ...grpc.CallOption) (*provider.InitiateFileUploadResponse, error) {
|
||||
return c.c.InitiateFileUpload(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) ListGrants(ctx context.Context, in *provider.ListGrantsRequest, opts ...grpc.CallOption) (*provider.ListGrantsResponse, error) {
|
||||
return c.c.ListGrants(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) ListContainerStream(ctx context.Context, in *provider.ListContainerStreamRequest, opts ...grpc.CallOption) (provider.ProviderAPI_ListContainerStreamClient, error) {
|
||||
return c.c.ListContainerStream(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) ListContainer(ctx context.Context, in *provider.ListContainerRequest, opts ...grpc.CallOption) (*provider.ListContainerResponse, error) {
|
||||
return c.c.ListContainer(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) ListFileVersions(ctx context.Context, in *provider.ListFileVersionsRequest, opts ...grpc.CallOption) (*provider.ListFileVersionsResponse, error) {
|
||||
return c.c.ListFileVersions(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) ListRecycleStream(ctx context.Context, in *provider.ListRecycleStreamRequest, opts ...grpc.CallOption) (provider.ProviderAPI_ListRecycleStreamClient, error) {
|
||||
return c.c.ListRecycleStream(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) ListRecycle(ctx context.Context, in *provider.ListRecycleRequest, opts ...grpc.CallOption) (*provider.ListRecycleResponse, error) {
|
||||
return c.c.ListRecycle(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) Move(ctx context.Context, in *provider.MoveRequest, opts ...grpc.CallOption) (*provider.MoveResponse, error) {
|
||||
return c.c.Move(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) RemoveGrant(ctx context.Context, in *provider.RemoveGrantRequest, opts ...grpc.CallOption) (*provider.RemoveGrantResponse, error) {
|
||||
return c.c.RemoveGrant(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) PurgeRecycle(ctx context.Context, in *provider.PurgeRecycleRequest, opts ...grpc.CallOption) (*provider.PurgeRecycleResponse, error) {
|
||||
return c.c.PurgeRecycle(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) RestoreFileVersion(ctx context.Context, in *provider.RestoreFileVersionRequest, opts ...grpc.CallOption) (*provider.RestoreFileVersionResponse, error) {
|
||||
return c.c.RestoreFileVersion(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) RestoreRecycleItem(ctx context.Context, in *provider.RestoreRecycleItemRequest, opts ...grpc.CallOption) (*provider.RestoreRecycleItemResponse, error) {
|
||||
return c.c.RestoreRecycleItem(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) UpdateGrant(ctx context.Context, in *provider.UpdateGrantRequest, opts ...grpc.CallOption) (*provider.UpdateGrantResponse, error) {
|
||||
return c.c.UpdateGrant(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) CreateSymlink(ctx context.Context, in *provider.CreateSymlinkRequest, opts ...grpc.CallOption) (*provider.CreateSymlinkResponse, error) {
|
||||
return c.c.CreateSymlink(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) CreateReference(ctx context.Context, in *provider.CreateReferenceRequest, opts ...grpc.CallOption) (*provider.CreateReferenceResponse, error) {
|
||||
return c.c.CreateReference(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) SetArbitraryMetadata(ctx context.Context, in *provider.SetArbitraryMetadataRequest, opts ...grpc.CallOption) (*provider.SetArbitraryMetadataResponse, error) {
|
||||
return c.c.SetArbitraryMetadata(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) UnsetArbitraryMetadata(ctx context.Context, in *provider.UnsetArbitraryMetadataRequest, opts ...grpc.CallOption) (*provider.UnsetArbitraryMetadataResponse, error) {
|
||||
return c.c.UnsetArbitraryMetadata(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) SetLock(ctx context.Context, in *provider.SetLockRequest, opts ...grpc.CallOption) (*provider.SetLockResponse, error) {
|
||||
return c.c.SetLock(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) GetLock(ctx context.Context, in *provider.GetLockRequest, opts ...grpc.CallOption) (*provider.GetLockResponse, error) {
|
||||
return c.c.GetLock(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) RefreshLock(ctx context.Context, in *provider.RefreshLockRequest, opts ...grpc.CallOption) (*provider.RefreshLockResponse, error) {
|
||||
return c.c.RefreshLock(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) Unlock(ctx context.Context, in *provider.UnlockRequest, opts ...grpc.CallOption) (*provider.UnlockResponse, error) {
|
||||
return c.c.Unlock(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) GetHome(ctx context.Context, in *provider.GetHomeRequest, opts ...grpc.CallOption) (*provider.GetHomeResponse, error) {
|
||||
return c.c.GetHome(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedAPIClient) TouchFile(ctx context.Context, in *provider.TouchFileRequest, opts ...grpc.CallOption) (*provider.TouchFileResponse, error) {
|
||||
return c.c.TouchFile(ctx, in, opts...)
|
||||
}
|
||||
+4
-45
@@ -34,12 +34,10 @@ import (
|
||||
|
||||
var (
|
||||
// DefaultStatCache is the memory store.
|
||||
statCaches = make(map[string]StatCache)
|
||||
providerCaches = make(map[string]ProviderCache)
|
||||
createHomeCaches = make(map[string]CreateHomeCache)
|
||||
createPersonalSpaceCaches = make(map[string]CreatePersonalSpaceCache)
|
||||
fileMetadataCaches = make(map[string]FileMetadataCache)
|
||||
mutex sync.Mutex
|
||||
statCaches = make(map[string]StatCache)
|
||||
providerCaches = make(map[string]ProviderCache)
|
||||
fileMetadataCaches = make(map[string]FileMetadataCache)
|
||||
mutex sync.Mutex
|
||||
)
|
||||
|
||||
// Config contains the configuring for a cache
|
||||
@@ -82,19 +80,6 @@ type ProviderCache interface {
|
||||
GetKey(userID *userpb.UserId, spaceID string) string
|
||||
}
|
||||
|
||||
// CreateHomeCache handles removing keys from a create home cache
|
||||
type CreateHomeCache interface {
|
||||
Cache
|
||||
RemoveCreateHome(res *provider.ResourceId)
|
||||
GetKey(userID *userpb.UserId) string
|
||||
}
|
||||
|
||||
// CreatePersonalSpaceCache handles removing keys from a create home cache
|
||||
type CreatePersonalSpaceCache interface {
|
||||
Cache
|
||||
GetKey(userID *userpb.UserId) string
|
||||
}
|
||||
|
||||
// FileMetadataCache handles file metadata
|
||||
type FileMetadataCache interface {
|
||||
Cache
|
||||
@@ -127,32 +112,6 @@ func GetProviderCache(cfg Config) ProviderCache {
|
||||
return providerCaches[key]
|
||||
}
|
||||
|
||||
// GetCreateHomeCache will return an existing CreateHomeCache for the given store, nodes, database and table
|
||||
// If it does not exist yet it will be created, different TTLs are ignored
|
||||
func GetCreateHomeCache(cfg Config) CreateHomeCache {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
||||
key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":")
|
||||
if createHomeCaches[key] == nil {
|
||||
createHomeCaches[key] = NewCreateHomeCache(cfg)
|
||||
}
|
||||
return createHomeCaches[key]
|
||||
}
|
||||
|
||||
// GetCreatePersonalSpaceCache will return an existing CreatePersonalSpaceCache for the given store, nodes, database and table
|
||||
// If it does not exist yet it will be created, different TTLs are ignored
|
||||
func GetCreatePersonalSpaceCache(cfg Config) CreatePersonalSpaceCache {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
||||
key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":")
|
||||
if createPersonalSpaceCaches[key] == nil {
|
||||
createPersonalSpaceCaches[key] = NewCreatePersonalSpaceCache(cfg)
|
||||
}
|
||||
return createPersonalSpaceCaches[key]
|
||||
}
|
||||
|
||||
// GetFileMetadataCache will return an existing GetFileMetadataCache for the given store, nodes, database and table
|
||||
// If it does not exist yet it will be created, different TTLs are ignored
|
||||
func GetFileMetadataCache(cfg Config) FileMetadataCache {
|
||||
|
||||
-67
@@ -1,67 +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 cache
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
)
|
||||
|
||||
// CreateHomeCache can invalidate all create home related cache entries
|
||||
type createHomeCache struct {
|
||||
cacheStore
|
||||
}
|
||||
|
||||
// NewCreateHomeCache creates a new CreateHomeCache
|
||||
func NewCreateHomeCache(cfg Config) CreateHomeCache {
|
||||
c := &createHomeCache{}
|
||||
c.s = getStore(cfg)
|
||||
c.database = cfg.Database
|
||||
c.table = cfg.Table
|
||||
c.ttl = cfg.TTL
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
// RemoveCreateHome removes a reference from the listproviders cache
|
||||
func (c createHomeCache) RemoveCreateHome(res *provider.ResourceId) {
|
||||
if res == nil {
|
||||
return
|
||||
}
|
||||
sid := res.SpaceId
|
||||
|
||||
keys, err := c.List()
|
||||
if err != nil {
|
||||
// FIXME log error
|
||||
return
|
||||
}
|
||||
// FIXME add context option to List, Read and Write to upstream
|
||||
for _, key := range keys {
|
||||
if strings.Contains(key, sid) {
|
||||
_ = c.Delete(key)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c createHomeCache) GetKey(userID *userpb.UserId) string {
|
||||
return userID.GetOpaqueId()
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
// Copyright 2018-2023 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 cache
|
||||
|
||||
import (
|
||||
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
)
|
||||
|
||||
// CreatePersonalSpaceCache can invalidate all create home related cache entries
|
||||
type createPersonalSpaceCache struct {
|
||||
cacheStore
|
||||
}
|
||||
|
||||
// NewCreatePersonalSpaceCache creates a new CreatePersonalSpaceCache
|
||||
func NewCreatePersonalSpaceCache(cfg Config) CreatePersonalSpaceCache {
|
||||
c := &createPersonalSpaceCache{}
|
||||
c.s = getStore(cfg)
|
||||
c.database = cfg.Database
|
||||
c.table = cfg.Table
|
||||
c.ttl = cfg.TTL
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c createPersonalSpaceCache) GetKey(userID *userpb.UserId) string {
|
||||
return userID.GetOpaqueId()
|
||||
}
|
||||
+16
-3
@@ -80,14 +80,27 @@ func (bs *Blobstore) Upload(node *node.Node, source string) error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not open blob '%s' for writing", dest)
|
||||
}
|
||||
defer func() {
|
||||
if cerr := f.Close(); cerr != nil && err == nil {
|
||||
err = errors.Wrapf(cerr, "could not close blob '%s'", dest)
|
||||
}
|
||||
}()
|
||||
|
||||
w := bufio.NewWriter(f)
|
||||
_, err = w.ReadFrom(file)
|
||||
if err != nil {
|
||||
if _, err = w.ReadFrom(file); err != nil {
|
||||
return errors.Wrapf(err, "could not write blob '%s'", dest)
|
||||
}
|
||||
|
||||
return w.Flush()
|
||||
if err = w.Flush(); err != nil {
|
||||
return errors.Wrapf(err, "could not flush blob '%s'", dest)
|
||||
}
|
||||
|
||||
// Ensure data is synced to disk before returning
|
||||
if err = f.Sync(); err != nil {
|
||||
return errors.Wrapf(err, "could not sync blob '%s' to disk", dest)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Download retrieves a blob from the blobstore for reading
|
||||
|
||||
+8
-5
@@ -59,14 +59,17 @@ func (bs *Blobstore) Upload(node *node.Node, source string) error {
|
||||
defer f.Close()
|
||||
|
||||
w := bufio.NewWriter(f)
|
||||
_, err = w.ReadFrom(file)
|
||||
if err != nil {
|
||||
if _, err = w.ReadFrom(file); err != nil {
|
||||
return errors.Wrapf(err, "could not write blob '%s'", node.InternalPath())
|
||||
}
|
||||
|
||||
err = w.Flush()
|
||||
if err != nil {
|
||||
return err
|
||||
if err = w.Flush(); err != nil {
|
||||
return errors.Wrapf(err, "could not flush blob '%s'", node.InternalPath())
|
||||
}
|
||||
|
||||
// Ensure data is synced to disk before returning
|
||||
if err = f.Sync(); err != nil {
|
||||
return errors.Wrapf(err, "could not sync blob '%s' to disk", node.InternalPath())
|
||||
}
|
||||
|
||||
if fi != nil {
|
||||
|
||||
Vendored
+1
-1
@@ -1316,7 +1316,7 @@ github.com/orcaman/concurrent-map
|
||||
# github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
## explicit; go 1.18
|
||||
github.com/owncloud/libre-graph-api-go
|
||||
# github.com/owncloud/reva/v2 v2.0.0-20260304131727-ce3149532498
|
||||
# github.com/owncloud/reva/v2 v2.0.0-20260323165509-10be73721fb2
|
||||
## explicit; go 1.24.0
|
||||
github.com/owncloud/reva/v2/cmd/revad/internal/grace
|
||||
github.com/owncloud/reva/v2/cmd/revad/runtime
|
||||
|
||||
Reference in new issue
Block a user