Merge pull request #9621 from owncloud/bump-reva-af606e7f

[full-ci] bump reva
This commit is contained in:
kobergj
2024-07-17 10:42:00 +02:00
committed by GitHub
12 changed files with 93 additions and 106 deletions
+2 -2
View File
@@ -1,3 +1,3 @@
# The test runner source for UI tests
WEB_COMMITID=862a4b4a419cf4e7cb2811c456675cd55a1924c6
WEB_BRANCH=master
WEB_COMMITID=5a27d947be3086543e3380c0ab9fe961af6ff358
WEB_BRANCH=useZipInsteadOfTar
+3
View File
@@ -0,0 +1,3 @@
Enhancement: Bump reva
https://github.com/owncloud/ocis/pull/9621
+1 -1
View File
@@ -15,7 +15,7 @@ require (
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/coreos/go-oidc/v3 v3.10.0
github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e
github.com/cs3org/reva/v2 v2.21.1-0.20240711153523-f9083e96d2ea
github.com/cs3org/reva/v2 v2.21.1-0.20240716111044-11ee452e19a7
github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
github.com/egirna/icap-client v0.1.1
+2 -2
View File
@@ -1025,8 +1025,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-20240425114016-d2cb31692b4e h1:Cm2l8m2riLa79eh7V2wHd1Ra7wR3TbngmeLZBJ9MxTU=
github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE=
github.com/cs3org/reva/v2 v2.21.1-0.20240711153523-f9083e96d2ea h1:fMT9FvEsfR+OLS4SWNNkxgUrCtgAuJABRTK+f+VRETk=
github.com/cs3org/reva/v2 v2.21.1-0.20240711153523-f9083e96d2ea/go.mod h1:+5pteFc4ymQnhYG2cOtg/jzaIZKgxrgIeH0D4fuC6gA=
github.com/cs3org/reva/v2 v2.21.1-0.20240716111044-11ee452e19a7 h1:3iy7UjtZQ0KtkuC0SM0HI7GF4nnwQGUCVzm9Vfrwh50=
github.com/cs3org/reva/v2 v2.21.1-0.20240716111044-11ee452e19a7/go.mod h1:+5pteFc4ymQnhYG2cOtg/jzaIZKgxrgIeH0D4fuC6gA=
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=
@@ -22,7 +22,7 @@ Feature: download multiple resources bundled into an archive
| textfile0.txt | some data |
Examples:
| user-agent | archive-type |
| Linux | tar |
| Linux | zip |
| Windows NT | zip |
@@ -40,7 +40,7 @@ Feature: download multiple resources bundled into an archive
| my_data/an_other_file.txt | more data |
Examples:
| user-agent | archive-type |
| Linux | tar |
| Linux | zip |
| Windows NT | zip |
@@ -57,7 +57,7 @@ Feature: download multiple resources bundled into an archive
| my_data |
| more_data |
Then the HTTP status code should be "200"
And the downloaded tar archive should contain these files:
And the downloaded zip archive should contain these files:
| name | content |
| textfile0.txt | some data |
| textfile1.txt | other data |
@@ -110,7 +110,7 @@ Feature: download multiple resources bundled into an archive
| /Shares/my_data |
| /Shares/more_data |
Then the HTTP status code should be "200"
And the downloaded tar archive should contain these files:
And the downloaded zip archive should contain these files:
| name | content |
| textfile0.txt | some data |
| textfile1.txt | other data |
@@ -21,7 +21,7 @@ Feature: Download space
Given user "Alice" has uploaded a file inside space "Project-space" with content "other data" to "file2.txt"
When user "Alice" downloads the space "Project-space" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded "tar" archive should contain these files:
And the downloaded "zip" archive should contain these files:
| name | content |
| file1.txt | some data |
| file2.txt | other data |
@@ -36,7 +36,7 @@ Feature: Download space
| permissionsRole | <space-role> |
When user "Brian" downloads the space "Project-space" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded "tar" archive should contain these files:
And the downloaded "zip" archive should contain these files:
| name | content |
| file1.txt | some data |
| .space/readme.md | space description |
@@ -24,7 +24,7 @@ Feature: Public can download folders from project space public link
| permissionsRole | view |
When public downloads the folder "NewFolder" from the last created public link using the public files API
Then the HTTP status code should be "200"
And the downloaded tar archive should contain these files:
And the downloaded zip archive should contain these files:
| name | content |
| NewFolder/test.txt | some content |
@@ -42,6 +42,6 @@ Feature: Public can download folders from project space public link
| permissionsRole | view |
When public downloads the folder "folder" from the last created public link using the public files API
Then the HTTP status code should be "200"
And the downloaded tar archive should contain these files:
And the downloaded zip archive should contain these files:
| name | content |
| folder/test.txt | some content |
@@ -841,7 +841,7 @@ func (s *svc) Unlock(ctx context.Context, req *provider.UnlockRequest) (*provide
// Stat returns the Resoure info for a given resource by forwarding the request to the responsible provider.
func (s *svc) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) {
c, _, ref, err := s.findAndUnwrapUnique(ctx, req.Ref)
c, _, ref, err := s.findAndUnwrap(ctx, req.Ref)
if err != nil {
return &provider.StatResponse{
Status: status.NewNotFound(ctx, fmt.Sprintf("gateway could not find space for ref=%+v", req.Ref)),
@@ -1019,30 +1019,6 @@ func (s *svc) GetQuota(ctx context.Context, req *gateway.GetQuotaRequest) (*prov
// - contains the provider path, which is the mount point of the provider
// - may contain a list of storage spaces with their id and space path
func (s *svc) find(ctx context.Context, ref *provider.Reference) (provider.ProviderAPIClient, *registry.ProviderInfo, error) {
p, err := s.findSpaces(ctx, ref)
if err != nil {
return nil, nil, err
}
client, err := s.getStorageProviderClient(ctx, p[0])
return client, p[0], err
}
// findSpacesProvider looks up the provider that is responsible for the given request
// It will return a client that the caller can use to make the call, as well as the ProviderInfo. It:
// - contains the provider path, which is the mount point of the provider
// - may contain a list of storage spaces with their id and space path
func (s *svc) findSpacesProvider(ctx context.Context, ref *provider.Reference) (provider.SpacesAPIClient, *registry.ProviderInfo, error) {
p, err := s.findSpaces(ctx, ref)
if err != nil {
return nil, nil, err
}
client, err := s.getSpacesProviderClient(ctx, p[0])
return client, p[0], err
}
func (s *svc) findUnique(ctx context.Context, ref *provider.Reference) (provider.ProviderAPIClient, *registry.ProviderInfo, error) {
p, err := s.findSingleSpace(ctx, ref)
if err != nil {
return nil, nil, err
@@ -1052,31 +1028,22 @@ func (s *svc) findUnique(ctx context.Context, ref *provider.Reference) (provider
return client, p[0], err
}
// FIXME findAndUnwrap currently just returns the first provider ... which may not be what is needed.
// for the ListRecycle call we need an exact match, for Stat and List we need to query all related providers
func (s *svc) findAndUnwrap(ctx context.Context, ref *provider.Reference) (provider.ProviderAPIClient, *registry.ProviderInfo, *provider.Reference, error) {
c, p, err := s.find(ctx, ref)
// findSpacesProvider looks up the spaces provider that is responsible for the given request
// It will return a client that the caller can use to make the call, as well as the ProviderInfo. It:
// - contains the provider path, which is the mount point of the provider
// - may contain a list of storage spaces with their id and space path
func (s *svc) findSpacesProvider(ctx context.Context, ref *provider.Reference) (provider.SpacesAPIClient, *registry.ProviderInfo, error) {
p, err := s.findSingleSpace(ctx, ref)
if err != nil {
return nil, nil, nil, err
return nil, nil, err
}
var (
root *provider.ResourceId
mountPath string
)
for _, space := range decodeSpaces(p) {
mountPath = decodePath(space)
root = space.Root
break // TODO can there be more than one space for a path?
}
relativeReference := unwrap(ref, mountPath, root)
return c, p, relativeReference, nil
client, err := s.getSpacesProviderClient(ctx, p[0])
return client, p[0], err
}
func (s *svc) findAndUnwrapUnique(ctx context.Context, ref *provider.Reference) (provider.ProviderAPIClient, *registry.ProviderInfo, *provider.Reference, error) {
c, p, err := s.findUnique(ctx, ref)
func (s *svc) findAndUnwrap(ctx context.Context, ref *provider.Reference) (provider.ProviderAPIClient, *registry.ProviderInfo, *provider.Reference, error) {
c, p, err := s.find(ctx, ref)
if err != nil {
return nil, nil, nil, err
}
@@ -1131,39 +1098,6 @@ func (s *svc) getStorageRegistryClient(_ context.Context, address string) (regis
}, nil
}
func (s *svc) findSpaces(ctx context.Context, ref *provider.Reference) ([]*registry.ProviderInfo, error) {
switch {
case ref == nil:
return nil, errtypes.BadRequest("missing reference")
case ref.ResourceId != nil:
if ref.ResourceId.OpaqueId == "" {
ref.ResourceId.OpaqueId = ref.ResourceId.SpaceId
}
case ref.Path != "": // TODO implement a mount path cache in the registry?
// nothing to do here either
default:
return nil, errtypes.BadRequest("invalid reference, at least path or id must be set")
}
filters := map[string]string{
"mask": "root", // we only need the root for routing
"path": ref.Path,
}
if ref.ResourceId != nil {
filters["storage_id"] = ref.ResourceId.StorageId
filters["space_id"] = ref.ResourceId.SpaceId
filters["opaque_id"] = ref.ResourceId.OpaqueId
}
listReq := &registry.ListStorageProvidersRequest{
Opaque: &typesv1beta1.Opaque{Map: make(map[string]*typesv1beta1.OpaqueEntry)},
}
sdk.EncodeOpaqueMap(listReq.Opaque, filters)
return s.findProvider(ctx, listReq)
}
func (s *svc) findSingleSpace(ctx context.Context, ref *provider.Reference) ([]*registry.ProviderInfo, error) {
switch {
case ref == nil:
+11 -10
View File
@@ -41,7 +41,6 @@ import (
"github.com/cs3org/reva/v2/pkg/storage/utils/walker"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/gdexlab/go-render/render"
ua "github.com/mileusna/useragent"
"github.com/mitchellh/mapstructure"
"github.com/rs/zerolog"
)
@@ -232,6 +231,10 @@ func (s *svc) Handler() http.Handler {
if !ok {
ids = []string{}
}
format := v.Get("output-format")
if format == "" {
format = "zip"
}
resources, err := s.getResources(ctx, paths, ids)
if err != nil {
@@ -248,26 +251,24 @@ func (s *svc) Handler() http.Handler {
return
}
userAgent := ua.Parse(r.Header.Get("User-Agent"))
archName := s.config.Name
if userAgent.OS == ua.Windows {
archName += ".zip"
} else {
if format == "tar" {
archName += ".tar"
} else {
archName += ".zip"
}
s.log.Debug().Msg("Requested the following resoucres to archive: " + render.Render(resources))
s.log.Debug().Msg("Requested the following resources to archive: " + render.Render(resources))
rw.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", archName))
rw.Header().Set("Content-Transfer-Encoding", "binary")
// create the archive
var closeArchive func()
if userAgent.OS == ua.Windows {
closeArchive, err = arch.CreateZip(ctx, rw)
} else {
if format == "tar" {
closeArchive, err = arch.CreateTar(ctx, rw)
} else {
closeArchive, err = arch.CreateZip(ctx, rw)
}
defer closeArchive()
+2 -2
View File
@@ -264,7 +264,7 @@ func (r *registry) GetProvider(ctx context.Context, space *providerpb.StorageSpa
// matches = /foo/bar <=> /foo/bar -> list(spaceid, .)
// below = /foo/bar/bif <=> /foo/bar -> list(spaceid, ./bif)
func (r *registry) ListProviders(ctx context.Context, filters map[string]string) ([]*registrypb.ProviderInfo, error) {
b, _ := strconv.ParseBool(filters["unique"])
unique, _ := strconv.ParseBool(filters["unique"])
unrestricted, _ := strconv.ParseBool(filters["unrestricted"])
mask := filters["mask"]
switch {
@@ -284,7 +284,7 @@ func (r *registry) ListProviders(ctx context.Context, filters map[string]string)
return r.findProvidersForResource(ctx, id, findMountpoint, findGrant, unrestricted, mask), nil
case filters["path"] != "":
return r.findProvidersForAbsolutePathReference(ctx, filters["path"], b, unrestricted, mask), nil
return r.findProvidersForAbsolutePathReference(ctx, filters["path"], unique, unrestricted, mask), nil
case len(filters) == 0:
// return all providers
return r.findAllProviders(ctx, mask), nil
@@ -354,8 +354,31 @@ func (store OcisStore) updateExistingNode(ctx context.Context, session *OcisSess
versionPath := session.store.lu.InternalPath(spaceID, n.ID+node.RevisionIDDelimiter+oldNodeMtime.UTC().Format(time.RFC3339Nano))
// create version node
if _, err := os.Create(versionPath); err != nil {
return unlock, err
_, err := os.OpenFile(versionPath, os.O_CREATE|os.O_EXCL, 0600)
if err != nil {
if !errors.Is(err, os.ErrExist) {
return unlock, err
}
// a revision with this mtime does already exist.
// If the blobs are the same we can just delete the old one
if err := validateChecksums(ctx, old, session, versionPath); err != nil {
return unlock, err
}
// delete old blob
bID, err := session.store.lu.ReadBlobIDAttr(ctx, versionPath)
if err != nil {
return unlock, err
}
if err := session.store.tp.DeleteBlob(&node.Node{BlobID: bID, SpaceID: n.SpaceID}); err != nil {
return unlock, err
}
// clean revision file
if _, err := os.Create(versionPath); err != nil {
return unlock, err
}
}
// copy blob metadata to version node
@@ -379,3 +402,29 @@ func (store OcisStore) updateExistingNode(ctx context.Context, session *OcisSess
return unlock, nil
}
func validateChecksums(ctx context.Context, n *node.Node, session *OcisSession, versionPath string) error {
for _, t := range []string{"md5", "sha1", "adler32"} {
key := prefixes.ChecksumPrefix + t
checksum, err := n.Xattr(ctx, key)
if err != nil {
return err
}
revisionChecksum, err := session.store.lu.MetadataBackend().Get(ctx, versionPath, key)
if err != nil {
return err
}
if string(checksum) == "" || string(revisionChecksum) == "" {
return errors.New("checksum not found")
}
if string(checksum) != string(revisionChecksum) {
return errors.New("checksum mismatch")
}
}
return nil
}
+1 -1
View File
@@ -366,7 +366,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.21.1-0.20240711153523-f9083e96d2ea
# github.com/cs3org/reva/v2 v2.21.1-0.20240716111044-11ee452e19a7
## explicit; go 1.21
github.com/cs3org/reva/v2/cmd/revad/internal/grace
github.com/cs3org/reva/v2/cmd/revad/runtime