diff --git a/changelog/unreleased/extend-eos-meta.md b/changelog/unreleased/extend-eos-meta.md new file mode 100644 index 0000000000..8204d188c3 --- /dev/null +++ b/changelog/unreleased/extend-eos-meta.md @@ -0,0 +1,6 @@ +Enhancement: Extend EOS metadata + +This PR extend the EOS metadata with atime and ctime fields. +This change is backwards compatible. + +https://github.com/cs3org/reva/pull/3954 diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index b120719363..ead7c21151 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -1190,6 +1190,32 @@ func (c *Client) mapToFileInfo(ctx context.Context, kv, attrs map[string]string, } } + var ctimesec, ctimenanos uint64 + if val, ok := kv["ctime"]; ok && val != "" { + split := strings.Split(val, ".") + ctimesec, err = strconv.ParseUint(split[0], 10, 64) + if err != nil { + return nil, err + } + ctimenanos, _ = strconv.ParseUint(split[1], 10, 32) + if err != nil { + return nil, err + } + } + + var atimesec, atimenanos uint64 + if val, ok := kv["atime"]; ok && val != "" { + split := strings.Split(val, ".") + atimesec, err = strconv.ParseUint(split[0], 10, 64) + if err != nil { + return nil, err + } + atimenanos, err = strconv.ParseUint(split[1], 10, 32) + if err != nil { + return nil, err + } + } + isDir := false var xs *eosclient.Checksum if _, ok := kv["files"]; ok { @@ -1239,6 +1265,10 @@ func (c *Client) mapToFileInfo(ctx context.Context, kv, attrs map[string]string, TreeSize: treeSize, MTimeSec: mtimesec, MTimeNanos: uint32(mtimenanos), + CTimeSec: ctimesec, + CTimeNanos: uint32(ctimenanos), + ATimeSec: atimesec, + ATimeNanos: uint32(atimenanos), IsDir: isDir, Instance: c.opt.URL, SysACL: sysACL, diff --git a/pkg/eosclient/eosclient.go b/pkg/eosclient/eosclient.go index 97d73950bc..6b93293683 100644 --- a/pkg/eosclient/eosclient.go +++ b/pkg/eosclient/eosclient.go @@ -74,13 +74,17 @@ type Attribute struct { // FileInfo represents the metadata information returned by querying the EOS namespace. type FileInfo struct { IsDir bool - MTimeNanos uint32 Inode uint64 `json:"inode"` FID uint64 `json:"fid"` UID uint64 `json:"uid"` GID uint64 `json:"gid"` TreeSize uint64 `json:"tree_size"` MTimeSec uint64 `json:"mtime_sec"` + MTimeNanos uint32 `json:"mtime_nanos"` + ATimeSec uint64 `json:"atime_sec"` + ATimeNanos uint32 `json:"atime_nanos"` + CTimeSec uint64 `json:"ctime_sec"` + CTimeNanos uint32 `json:"ctime_nanos"` Size uint64 `json:"size"` TreeCount uint64 `json:"tree_count"` File string `json:"eos_file"`