Merge pull request #10347 from owncloud/bump-reva-to-c17f69457a13

bump reva to c17f69457a13
This commit is contained in:
Jörn Friedrich Dreyer
2024-10-18 15:12:58 +02:00
committed by GitHub
16 changed files with 52 additions and 54 deletions

View File

@@ -2,6 +2,7 @@ Enhancement: Bump reva to 2.xx.x
TODO
https://github.com/owncloud/ocis/pull/10347
https://github.com/owncloud/ocis/pull/10321
https://github.com/owncloud/ocis/pull/10236
https://github.com/owncloud/ocis/pull/10216

2
go.mod
View File

@@ -15,7 +15,7 @@ require (
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/coreos/go-oidc/v3 v3.11.0
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb
github.com/cs3org/reva/v2 v2.25.1-0.20241016145214-e5baaccf6614
github.com/cs3org/reva/v2 v2.25.1-0.20241018101549-c17f69457a13
github.com/davidbyttow/govips/v2 v2.15.0
github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e

4
go.sum
View File

@@ -250,8 +250,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c=
github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME=
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU=
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE=
github.com/cs3org/reva/v2 v2.25.1-0.20241016145214-e5baaccf6614 h1:f9s9KJoxM+EKlBKLhD4LsoqcELYct4DLToqXPJj/mC0=
github.com/cs3org/reva/v2 v2.25.1-0.20241016145214-e5baaccf6614/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI=
github.com/cs3org/reva/v2 v2.25.1-0.20241018101549-c17f69457a13 h1:GA3DMDNh2Ggpnp5hVO9Mu9i0bkro/gTb0poY5hUYq44=
github.com/cs3org/reva/v2 v2.25.1-0.20241018101549-c17f69457a13/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=

View File

@@ -720,7 +720,7 @@ func (s *Service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro
if req.Opaque != nil {
if _, ok := req.Opaque.Map["deleting_shared_resource"]; ok {
// it is a binary key; its existence signals true. Although, do not assume.
ctx = context.WithValue(ctx, appctx.DeletingSharedResource, true)
ctx = appctx.WithDeletingSharedResource(ctx)
}
}
@@ -1095,6 +1095,16 @@ func (s *Service) DenyGrant(ctx context.Context, req *provider.DenyGrantRequest)
return res, nil
}
type spaceTypeKey struct{}
func WithSpaceType(ctx context.Context, spaceType string) context.Context {
return context.WithValue(ctx, spaceTypeKey{}, spaceType)
}
func SpaceTypeFromContext(ctx context.Context) (string, bool) {
spaceType, ok := ctx.Value(spaceTypeKey{}).(string)
return spaceType, ok
}
func (s *Service) AddGrant(ctx context.Context, req *provider.AddGrantRequest) (*provider.AddGrantResponse, error) {
ctx = ctxpkg.ContextSetLockID(ctx, req.LockId)
@@ -1102,13 +1112,7 @@ func (s *Service) AddGrant(ctx context.Context, req *provider.AddGrantRequest) (
// FIXME these should be part of the AddGrantRequest object
// https://github.com/owncloud/ocis/issues/4312
if utils.ExistsInOpaque(req.Opaque, "spacegrant") {
ctx = context.WithValue(
ctx,
utils.SpaceGrant,
struct{ SpaceType string }{
SpaceType: utils.ReadPlainFromOpaque(req.Opaque, "spacetype"),
},
)
ctx = WithSpaceType(ctx, utils.ReadPlainFromOpaque(req.Opaque, "spacetype"))
}
// check grantee type is valid
@@ -1137,13 +1141,7 @@ func (s *Service) UpdateGrant(ctx context.Context, req *provider.UpdateGrantRequ
// FIXME these should be part of the AddGrantRequest object
// https://github.com/owncloud/ocis/issues/4312
if utils.ExistsInOpaque(req.Opaque, "spacegrant") {
ctx = context.WithValue(
ctx,
utils.SpaceGrant,
struct{ SpaceType string }{
SpaceType: utils.ReadPlainFromOpaque(req.Opaque, "spacetype"),
},
)
ctx = WithSpaceType(ctx, utils.ReadPlainFromOpaque(req.Opaque, "spacetype"))
}
// check grantee type is valid
@@ -1174,7 +1172,7 @@ func (s *Service) RemoveGrant(ctx context.Context, req *provider.RemoveGrantRequ
// FIXME these should be part of the RemoveGrantRequest object
// https://github.com/owncloud/ocis/issues/4312
if utils.ExistsInOpaque(req.Opaque, "spacegrant") {
ctx = context.WithValue(ctx, utils.SpaceGrant, struct{}{})
ctx = WithSpaceType(ctx, "")
}
err := s.Storage.RemoveGrant(ctx, req.Ref, req.Grant)

View File

@@ -21,7 +21,6 @@ package errors
import (
"bytes"
"encoding/xml"
"fmt"
"net/http"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
@@ -210,6 +209,6 @@ func NewErrFromStatus(s *rpc.Status) error {
case rpc.Code_CODE_UNIMPLEMENTED:
return ErrNotImplemented
default:
return fmt.Errorf(s.GetMessage())
return errors.New(s.GetMessage())
}
}

View File

@@ -148,13 +148,13 @@ func (s *svc) handleMkcol(ctx context.Context, w http.ResponseWriter, r *http.Re
}
return http.StatusForbidden, errors.New(sRes.Status.Message)
case res.Status.Code == rpc.Code_CODE_ABORTED:
return http.StatusPreconditionFailed, fmt.Errorf(res.Status.Message)
return http.StatusPreconditionFailed, errors.New(res.Status.Message)
case res.Status.Code == rpc.Code_CODE_FAILED_PRECONDITION:
// https://www.rfc-editor.org/rfc/rfc4918#section-9.3.1:
// 409 (Conflict) - A collection cannot be made at the Request-URI until
// one or more intermediate collections have been created. The server
// MUST NOT create those intermediate collections automatically.
return http.StatusConflict, fmt.Errorf(res.Status.Message)
return http.StatusConflict, errors.New(res.Status.Message)
case res.Status.Code == rpc.Code_CODE_ALREADY_EXISTS:
// https://www.rfc-editor.org/rfc/rfc4918#section-9.3.1:
// 405 (Method Not Allowed) - MKCOL can only be executed on an unmapped URL.

View File

@@ -335,17 +335,14 @@ func getSharedResource(ctx context.Context, client gateway.GatewayAPIClient, res
},
})
if err != nil {
e := fmt.Errorf("could not get reference")
return nil, arbitraryOcsResponse(response.MetaServerError.StatusCode, e.Error())
return nil, arbitraryOcsResponse(response.MetaServerError.StatusCode, "could not get reference")
}
if res.Status.Code != rpc.Code_CODE_OK {
if res.Status.Code == rpc.Code_CODE_NOT_FOUND {
e := fmt.Errorf("not found")
return nil, arbitraryOcsResponse(response.MetaNotFound.StatusCode, e.Error())
return nil, arbitraryOcsResponse(response.MetaNotFound.StatusCode, "not found")
}
e := fmt.Errorf(res.GetStatus().GetMessage())
return nil, arbitraryOcsResponse(response.MetaServerError.StatusCode, e.Error())
return nil, arbitraryOcsResponse(response.MetaServerError.StatusCode, res.GetStatus().GetMessage())
}
return res, nil

View File

@@ -27,8 +27,15 @@ import (
"go.opentelemetry.io/otel/trace"
)
// DeletingSharedResource flags to a storage a shared resource is being deleted not by the owner.
var DeletingSharedResource struct{}
// deletingSharedResource flags to a storage a shared resource is being deleted not by the owner.
type deletingSharedResource struct{}
func WithDeletingSharedResource(ctx context.Context) context.Context {
return context.WithValue(ctx, deletingSharedResource{}, struct{}{})
}
func DeletingSharedResourceFromContext(ctx context.Context) bool {
return ctx.Value(deletingSharedResource{}) != nil
}
// WithLogger returns a context with an associated logger.
func WithLogger(ctx context.Context, l *zerolog.Logger) context.Context {

View File

@@ -19,6 +19,7 @@
package importers
import (
"errors"
"fmt"
"strings"
"sync"
@@ -70,7 +71,7 @@ func (importer *BaseImporter) Process(connectors *connectors.Collection) (bool,
var err error
if len(processErrs) != 0 {
err = fmt.Errorf(strings.Join(processErrs, "; "))
err = errors.New(strings.Join(processErrs, "; "))
}
return true, err
}

View File

@@ -25,7 +25,6 @@ import (
"fmt"
"io"
"net/http"
"strconv"
"strings"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
@@ -431,7 +430,7 @@ func (sm *Manager) do(ctx context.Context, a Action, username string) (int, []by
log.Info().Msgf("am.do response %d %s", resp.StatusCode, body)
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
return 0, nil, fmt.Errorf("Unexpected response code from EFSS API: " + strconv.Itoa(resp.StatusCode))
return 0, nil, fmt.Errorf("Unexpected response code from EFSS API: %d", resp.StatusCode)
}
return resp.StatusCode, body, nil
}

View File

@@ -467,9 +467,7 @@ func (t *Tree) Delete(ctx context.Context, n *node.Node) error {
// remove entry from cache immediately to avoid inconsistencies
defer func() { _ = t.idCache.Delete(path) }()
deletingSharedResource := ctx.Value(appctx.DeletingSharedResource)
if deletingSharedResource != nil && deletingSharedResource.(bool) {
if appctx.DeletingSharedResourceFromContext(ctx) {
src := filepath.Join(n.ParentPath(), n.Name)
return os.RemoveAll(src)
}

View File

@@ -24,6 +24,7 @@ import (
"strings"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/internal/grpc/services/storageprovider"
"github.com/cs3org/reva/v2/pkg/appctx"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/errtypes"
@@ -227,7 +228,8 @@ func (fs *Decomposedfs) RemoveGrant(ctx context.Context, ref *provider.Reference
}
func isShareGrant(ctx context.Context) bool {
return ctx.Value(utils.SpaceGrant) == nil
_, ok := storageprovider.SpaceTypeFromContext(ctx)
return !ok
}
// UpdateGrant updates a grant on a resource
@@ -306,16 +308,12 @@ func (fs *Decomposedfs) loadGrant(ctx context.Context, ref *provider.Reference,
}
func (fs *Decomposedfs) storeGrant(ctx context.Context, n *node.Node, g *provider.Grant) error {
var spaceType string
spaceGrant := ctx.Value(utils.SpaceGrant)
// this is not a grant on a space root we are just adding a share
if spaceGrant == nil {
// if is a grant to a space root, the receiver needs the space type to update the indexes
spaceType, ok := storageprovider.SpaceTypeFromContext(ctx)
if !ok {
// this is not a grant on a space root we are just adding a share
spaceType = spaceTypeShare
}
// this is a grant to a space root, the receiver needs the space type to update the indexes
if sg, ok := spaceGrant.(struct{ SpaceType string }); ok && sg.SpaceType != "" {
spaceType = sg.SpaceType
}
// set the grant
e := ace.FromGrant(g)

View File

@@ -34,6 +34,7 @@ import (
v1beta11 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/v2/internal/grpc/services/storageprovider"
"github.com/cs3org/reva/v2/pkg/appctx"
ocsconv "github.com/cs3org/reva/v2/pkg/conversions"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
@@ -65,7 +66,7 @@ const (
// CreateStorageSpace creates a storage space
func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.CreateStorageSpaceRequest) (*provider.CreateStorageSpaceResponse, error) {
ctx = context.WithValue(ctx, utils.SpaceGrant, struct{}{})
ctx = storageprovider.WithSpaceType(ctx, "")
u := ctxpkg.ContextMustGetUser(ctx)
// "everything is a resource" this is the unique ID for the Space resource.
@@ -195,7 +196,7 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr
return nil, err
}
ctx = context.WithValue(ctx, utils.SpaceGrant, struct{ SpaceType string }{SpaceType: req.Type})
ctx = storageprovider.WithSpaceType(ctx, req.Type)
if req.Type != _spaceTypePersonal {
if err := fs.AddGrant(ctx, &provider.Reference{

View File

@@ -440,9 +440,7 @@ func (t *Tree) Delete(ctx context.Context, n *node.Node) (err error) {
// remove entry from cache immediately to avoid inconsistencies
defer func() { _ = t.idCache.Delete(path) }()
deletingSharedResource := ctx.Value(appctx.DeletingSharedResource)
if deletingSharedResource != nil && deletingSharedResource.(bool) {
if appctx.DeletingSharedResourceFromContext(ctx) {
src := filepath.Join(n.ParentPath(), n.Name)
return os.Remove(src)
}

View File

@@ -178,7 +178,6 @@ func (session *OcisSession) FinishUpload(ctx context.Context) error {
return err
}
}
// increase the processing counter for every started processing
// will be decreased in Cleanup()
metrics.UploadProcessing.Inc()
@@ -213,7 +212,9 @@ func (session *OcisSession) FinishUpload(ctx context.Context) error {
}
}
if !session.store.async {
// if the upload is synchronous or the upload is empty, finalize it now
// for 0-byte uploads we take a shortcut and finalize isn't called elsewhere
if !session.store.async || session.info.Size == 0 {
// handle postprocessing synchronously
err = session.Finalize()
session.store.Cleanup(ctx, session, err != nil, false, err == nil)

2
vendor/modules.txt vendored
View File

@@ -364,7 +364,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.25.1-0.20241016145214-e5baaccf6614
# github.com/cs3org/reva/v2 v2.25.1-0.20241018101549-c17f69457a13
## explicit; go 1.21
github.com/cs3org/reva/v2/cmd/revad/internal/grace
github.com/cs3org/reva/v2/cmd/revad/runtime