Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return file checksum available from the metadata for the EOS driver #1755

Merged
merged 2 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/eos-xs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Return file checksum available from the metadata for the EOS driver

https://github.com/cs3org/reva/pull/1755
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 7 additions & 0 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down