From fb73ec255e9cd22488bcfbcebdb4b5ed97d1d797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 18 Oct 2024 12:20:41 +0200 Subject: [PATCH] bump reva to c17f69457a13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/bump-reva.md | 1 + go.mod | 2 +- go.sum | 4 +-- .../storageprovider/storageprovider.go | 30 +++++++++---------- .../services/owncloud/ocdav/errors/error.go | 3 +- .../http/services/owncloud/ocdav/mkcol.go | 4 +-- .../handlers/apps/sharing/shares/pending.go | 9 ++---- .../cs3org/reva/v2/pkg/appctx/appctx.go | 11 +++++-- .../mentix/exchangers/importers/importer.go | 3 +- .../share/repository/nextcloud/nextcloud.go | 3 +- .../reva/v2/pkg/storage/fs/posix/tree/tree.go | 4 +-- .../pkg/storage/utils/decomposedfs/grants.go | 16 +++++----- .../pkg/storage/utils/decomposedfs/spaces.go | 5 ++-- .../storage/utils/decomposedfs/tree/tree.go | 4 +-- .../utils/decomposedfs/upload/upload.go | 5 ++-- vendor/modules.txt | 2 +- 16 files changed, 52 insertions(+), 54 deletions(-) diff --git a/changelog/unreleased/bump-reva.md b/changelog/unreleased/bump-reva.md index 44df4ceeda2..5021b5f792f 100644 --- a/changelog/unreleased/bump-reva.md +++ b/changelog/unreleased/bump-reva.md @@ -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 diff --git a/go.mod b/go.mod index c8db95b41ca..3e2097dc59c 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 030e65c2a81..2be99b4149a 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/storageprovider/storageprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/storageprovider/storageprovider.go index 872105788e0..80c6ef0b84a 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/storageprovider/storageprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/storageprovider/storageprovider.go @@ -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) diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors/error.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors/error.go index 2709eb5ca32..69cc31afd85 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors/error.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors/error.go @@ -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()) } } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/mkcol.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/mkcol.go index 1a1f57e75b0..4e884616719 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/mkcol.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/mkcol.go @@ -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. diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go index 95028624460..e7cf9cdd04f 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go @@ -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 diff --git a/vendor/github.com/cs3org/reva/v2/pkg/appctx/appctx.go b/vendor/github.com/cs3org/reva/v2/pkg/appctx/appctx.go index 78fe950d19f..067cd4d8440 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/appctx/appctx.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/appctx/appctx.go @@ -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 { diff --git a/vendor/github.com/cs3org/reva/v2/pkg/mentix/exchangers/importers/importer.go b/vendor/github.com/cs3org/reva/v2/pkg/mentix/exchangers/importers/importer.go index bd1c58672be..517518c8e47 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/mentix/exchangers/importers/importer.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/mentix/exchangers/importers/importer.go @@ -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 } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/ocm/share/repository/nextcloud/nextcloud.go b/vendor/github.com/cs3org/reva/v2/pkg/ocm/share/repository/nextcloud/nextcloud.go index 0ce4ac817ac..7b89faf06fe 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/ocm/share/repository/nextcloud/nextcloud.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/ocm/share/repository/nextcloud/nextcloud.go @@ -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 } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/tree/tree.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/tree/tree.go index be08736b9a3..f41ab1dfb95 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/tree/tree.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/tree/tree.go @@ -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) } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/grants.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/grants.go index 227a2d5d494..167fb6a5d6c 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/grants.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/grants.go @@ -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) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go index ea51869e2ca..c8f4268a33a 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go @@ -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{ diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go index 58dc0c4e1ff..31ade9af4fd 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go @@ -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) } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go index f3a2fed4761..427af92dbc3 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go @@ -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) diff --git a/vendor/modules.txt b/vendor/modules.txt index 76b654b6849..ecc2c79bd1c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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