Merge pull request #6785 from aduffeck/bump-reva

Bump reva to pull in the fix for the space index data structure
This commit is contained in:
Andre Duffeck
2023-07-13 09:49:11 +02:00
committed by GitHub
7 changed files with 99 additions and 16 deletions

2
go.mod
View File

@@ -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

4
go.sum
View File

@@ -625,8 +625,8 @@ 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=
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=

View File

@@ -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) {

View File

@@ -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.

View File

@@ -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
}

View File

@@ -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"

2
vendor/modules.txt vendored
View File

@@ -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