From 6d5acc03ae04d36e03b038de738e3d7012238382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 12 Jul 2023 15:22:22 +0200 Subject: [PATCH 1/2] Bump reva to pull in the fix for the space index data structure Fixes https://github.com/owncloud/ocis/issues/6781 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6797608c7..535819180 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.6.0 github.com/cs3org/go-cs3apis v0.0.0-20230516150832-730ac860c71d - github.com/cs3org/reva/v2 v2.14.1-0.20230711102918-b095db01ac36 + github.com/cs3org/reva/v2 v2.14.1-0.20230712131605-76f38842c6d2 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e github.com/egirna/icap-client v0.1.1 diff --git a/go.sum b/go.sum index 5c80c1550..b952ae46b 100644 --- a/go.sum +++ b/go.sum @@ -627,6 +627,8 @@ github.com/crewjam/saml v0.4.13 h1:TYHggH/hwP7eArqiXSJUvtOPNzQDyQ7vwmwEqlFWhMc= github.com/crewjam/saml v0.4.13/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA= github.com/cs3org/reva/v2 v2.14.1-0.20230711102918-b095db01ac36 h1:Jww+ia7QQPE6zctpRb60iflrAaasRxNl9AfmOyM8Fw0= github.com/cs3org/reva/v2 v2.14.1-0.20230711102918-b095db01ac36/go.mod h1:4z5EQghS2LhSWZWocH51Dw9VAs16No1zSFvFgQtgS7w= +github.com/cs3org/reva/v2 v2.14.1-0.20230712131605-76f38842c6d2 h1:i9hn9nmcLLezXh4Dt9aa867CtCXQhNujEWTL+4+M3S4= +github.com/cs3org/reva/v2 v2.14.1-0.20230712131605-76f38842c6d2/go.mod h1:4z5EQghS2LhSWZWocH51Dw9VAs16No1zSFvFgQtgS7w= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= From 35c75e08a1010e3ad66194db4ce1ecb03307bcc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 12 Jul 2023 15:29:57 +0200 Subject: [PATCH 2/2] tidy/vendor go modules --- go.sum | 2 - .../publicshareprovider.go | 31 ++++++--- .../v2/pkg/publicshare/manager/json/json.go | 6 +- ...0005_fix_messagepack_space_index_format.go | 68 +++++++++++++++++++ .../utils/decomposedfs/migrator/migrator.go | 2 +- vendor/modules.txt | 2 +- 6 files changed, 96 insertions(+), 15 deletions(-) create mode 100644 vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/migrator/0005_fix_messagepack_space_index_format.go diff --git a/go.sum b/go.sum index b952ae46b..aebb344b4 100644 --- a/go.sum +++ b/go.sum @@ -625,8 +625,6 @@ github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= github.com/crewjam/saml v0.4.13 h1:TYHggH/hwP7eArqiXSJUvtOPNzQDyQ7vwmwEqlFWhMc= github.com/crewjam/saml v0.4.13/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA= -github.com/cs3org/reva/v2 v2.14.1-0.20230711102918-b095db01ac36 h1:Jww+ia7QQPE6zctpRb60iflrAaasRxNl9AfmOyM8Fw0= -github.com/cs3org/reva/v2 v2.14.1-0.20230711102918-b095db01ac36/go.mod h1:4z5EQghS2LhSWZWocH51Dw9VAs16No1zSFvFgQtgS7w= github.com/cs3org/reva/v2 v2.14.1-0.20230712131605-76f38842c6d2 h1:i9hn9nmcLLezXh4Dt9aa867CtCXQhNujEWTL+4+M3S4= github.com/cs3org/reva/v2 v2.14.1-0.20230712131605-76f38842c6d2/go.mod h1:4z5EQghS2LhSWZWocH51Dw9VAs16No1zSFvFgQtgS7w= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/publicshareprovider/publicshareprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/publicshareprovider/publicshareprovider.go index 7f7e30166..e8f18aea6 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/publicshareprovider/publicshareprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/publicshareprovider/publicshareprovider.go @@ -22,6 +22,7 @@ import ( "context" "regexp" + rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1" "github.com/cs3org/reva/v2/pkg/appctx" ctxpkg "github.com/cs3org/reva/v2/pkg/ctx" @@ -218,15 +219,29 @@ func (s *service) GetPublicShare(ctx context.Context, req *link.GetPublicShareRe log.Error().Msg("error getting user from context") } - found, err := s.sm.GetPublicShare(ctx, u, req.Ref, req.GetSign()) - if err != nil { - return nil, err + ps, err := s.sm.GetPublicShare(ctx, u, req.Ref, req.GetSign()) + switch { + case err != nil: + var st *rpc.Status + switch err.(type) { + case errtypes.IsNotFound: + st = status.NewNotFound(ctx, err.Error()) + default: + st = status.NewInternal(ctx, err.Error()) + } + return &link.GetPublicShareResponse{ + Status: st, + }, nil + case ps == nil: + return &link.GetPublicShareResponse{ + Status: status.NewNotFound(ctx, "not found"), + }, nil + default: + return &link.GetPublicShareResponse{ + Status: status.NewOK(ctx), + Share: ps, + }, nil } - - return &link.GetPublicShareResponse{ - Status: status.NewOK(ctx), - Share: found, - }, nil } func (s *service) ListPublicShares(ctx context.Context, req *link.ListPublicSharesRequest) (*link.ListPublicSharesResponse, error) { diff --git a/vendor/github.com/cs3org/reva/v2/pkg/publicshare/manager/json/json.go b/vendor/github.com/cs3org/reva/v2/pkg/publicshare/manager/json/json.go index bad4767ec..5d7673b82 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/publicshare/manager/json/json.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/publicshare/manager/json/json.go @@ -430,7 +430,7 @@ func (m *manager) GetPublicShare(ctx context.Context, u *user.User, ref *link.Pu if ref.GetToken() != "" { ps, pw, err := m.getByToken(ctx, ref.GetToken()) if err != nil { - return nil, errors.New("no shares found by token") + return nil, errtypes.NotFound("no shares found by token") } if ps.PasswordProtected && sign { err := publicshare.AddSignature(ps, pw) @@ -463,7 +463,7 @@ func (m *manager) GetPublicShare(ctx context.Context, u *user.User, ref *link.Pu if err := m.revokeExpiredPublicShare(ctx, &ps, u); err != nil { return nil, err } - return nil, errors.New("no shares found by id:" + ref.GetId().String()) + return nil, errtypes.NotFound("no shares found by id:" + ref.GetId().String()) } if ps.PasswordProtected && sign { err := publicshare.AddSignature(&ps, passDB) @@ -475,7 +475,7 @@ func (m *manager) GetPublicShare(ctx context.Context, u *user.User, ref *link.Pu } } - return nil, errors.New("no shares found by id:" + ref.GetId().String()) + return nil, errtypes.NotFound("no shares found by id:" + ref.GetId().String()) } // ListPublicShares retrieves all the shares on the manager that are valid. diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/migrator/0005_fix_messagepack_space_index_format.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/migrator/0005_fix_messagepack_space_index_format.go new file mode 100644 index 000000000..ca69fd869 --- /dev/null +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/migrator/0005_fix_messagepack_space_index_format.go @@ -0,0 +1,68 @@ +// 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 migrator + +import ( + "os" + "path/filepath" + + "github.com/shamaton/msgpack/v2" +) + +// Migration0005 fixes the messagepack space index data structure +func (m *Migrator) Migration0005() (Result, error) { + root := m.lu.InternalRoot() + + indexes, err := filepath.Glob(filepath.Join(root, "indexes", "**", "*.mpk")) + if err != nil { + return resultFailed, err + } + for _, i := range indexes { + m.log.Info().Str("root", m.lu.InternalRoot()).Msg("Fixing index format of " + i) + + // Read old-format index + oldData, err := os.ReadFile(i) + if err != nil { + return resultFailed, err + } + oldIndex := map[string][]byte{} + err = msgpack.Unmarshal(oldData, &oldIndex) + if err != nil { + // likely already migrated -> skip + m.log.Warn().Str("root", m.lu.InternalRoot()).Msg("Invalid index format found in " + i) + continue + } + + // Write new-format index + newIndex := map[string]string{} + for k, v := range oldIndex { + newIndex[k] = string(v) + } + newData, err := msgpack.Marshal(newIndex) + if err != nil { + return resultFailed, err + } + err = os.WriteFile(i, newData, 0600) + if err != nil { + return resultFailed, err + } + } + m.log.Info().Msg("done.") + return resultSucceeded, nil +} diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/migrator/migrator.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/migrator/migrator.go index 13b5c91da..17001e802 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/migrator/migrator.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/migrator/migrator.go @@ -29,7 +29,7 @@ import ( "github.com/rs/zerolog" ) -var allMigrations = []string{"0001", "0002", "0003", "0004"} +var allMigrations = []string{"0001", "0002", "0003", "0004", "0005"} const ( resultFailed = "failed" diff --git a/vendor/modules.txt b/vendor/modules.txt index a317cd1fe..c2d5a95ca 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -352,7 +352,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.14.1-0.20230711102918-b095db01ac36 +# github.com/cs3org/reva/v2 v2.14.1-0.20230712131605-76f38842c6d2 ## explicit; go 1.20 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime