From 39fd31240071d2cc2c6fc010f29cdae8adb4ce9f Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Wed, 2 Jun 2021 15:06:16 +0200 Subject: [PATCH 1/2] Return file checksum available from the metadata for the EOS driver --- changelog/unreleased/eos-xs.md | 3 +++ pkg/eosclient/eosbinary/eosbinary.go | 7 +++++++ pkg/eosclient/eosclient.go | 7 +++++++ pkg/storage/utils/eosfs/eosfs.go | 12 ++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 changelog/unreleased/eos-xs.md diff --git a/changelog/unreleased/eos-xs.md b/changelog/unreleased/eos-xs.md new file mode 100644 index 0000000000..ce18503ebd --- /dev/null +++ b/changelog/unreleased/eos-xs.md @@ -0,0 +1,3 @@ +Enhancement: Return file checksum available from the metadata for the EOS driver + +https://github.com/cs3org/reva/pull/1755 diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index bb22ce5bcf..8d5207f896 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -907,8 +907,14 @@ func (c *Client) mapToFileInfo(kv map[string]string) (*eosclient.FileInfo, error } isDir := false + var xs *eosclient.Checksum if _, ok := kv["files"]; ok { isDir = true + } else { + xs = &eosclient.Checksum{ + XSSum: kv["xs"], + XSType: kv["xstype"], + } } sysACL, err := acl.Parse(kv["sys.acl"], acl.ShortTextForm) @@ -932,6 +938,7 @@ func (c *Client) mapToFileInfo(kv map[string]string) (*eosclient.FileInfo, error SysACL: sysACL, TreeCount: treeCount, Attrs: kv, + XS: xs, } return fi, nil diff --git a/pkg/eosclient/eosclient.go b/pkg/eosclient/eosclient.go index 1425ed5ac7..e9726c91d2 100644 --- a/pkg/eosclient/eosclient.go +++ b/pkg/eosclient/eosclient.go @@ -82,6 +82,7 @@ type FileInfo struct { File string `json:"eos_file"` ETag string `json:"etag"` Instance string `json:"instance"` + XS *Checksum `json:"xs"` SysACL *acl.ACLs `json:"sys_acl"` Attrs map[string]string `json:"attrs"` } @@ -95,6 +96,12 @@ type DeletedEntry struct { IsDir bool } +// Checksum represents a cheksum entry for a file returned by EOS. +type Checksum struct { + XSSum string + XSType string +} + // QuotaInfo reports the available bytes and inodes for a particular user. // eos reports all quota values are unsigned long, see https://github.com/cern-eos/eos/blob/93515df8c0d5a858982853d960bec98f983c1285/mgm/Quota.hh#L135 type QuotaInfo struct { diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index ba6c8de598..70cee23571 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -1452,6 +1452,17 @@ func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo, v } } + var xs provider.ResourceChecksum + if eosFileInfo.XS != nil { + xs.Sum = eosFileInfo.XS.XSSum + switch eosFileInfo.XS.XSType { + case "adler": + xs.Type = provider.ResourceChecksumType_RESOURCE_CHECKSUM_TYPE_ADLER32 + default: + xs.Type = provider.ResourceChecksumType_RESOURCE_CHECKSUM_TYPE_INVALID + } + } + info := &provider.ResourceInfo{ Id: &provider.ResourceId{OpaqueId: fmt.Sprintf("%d", eosFileInfo.Inode)}, Path: path, @@ -1460,6 +1471,7 @@ func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo, v MimeType: mime.Detect(eosFileInfo.IsDir, path), Size: size, PermissionSet: fs.permissionSet(ctx, eosFileInfo, owner), + Checksum: &xs, Mtime: &types.Timestamp{ Seconds: eosFileInfo.MTimeSec, Nanos: eosFileInfo.MTimeNanos, From a83dc894c9ac20854d8b2edadf00f7b3c6f3eb9d Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Wed, 2 Jun 2021 15:18:33 +0200 Subject: [PATCH 2/2] Update ginkgo --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index e366171737..5c55b4f44f 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/minio/minio-go/v7 v7.0.10 github.com/mitchellh/copystructure v1.0.0 // indirect github.com/mitchellh/mapstructure v1.4.1 - github.com/onsi/ginkgo v1.16.2 + github.com/onsi/ginkgo v1.16.3 github.com/onsi/gomega v1.13.0 github.com/ory/fosite v0.40.2 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index bb20fe3759..6b1218aa21 100644 --- a/go.sum +++ b/go.sum @@ -913,8 +913,9 @@ github.com/onsi/ginkgo v1.9.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.2 h1:HFB2fbVIlhIfCfOW81bZFbiC/RvnpXSdhbF2/DJr134= github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= +github.com/onsi/ginkgo v1.16.3 h1:3s86PZkI1ApJh6HFIzC1gXby/mIyZqfE5zxSvtoBSsM= +github.com/onsi/ginkgo v1.16.3/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=