Skip to content

Commit

Permalink
eosclient: extend eos metadata with atime/ctime (cs3org#3954)
Browse files Browse the repository at this point in the history
* eosclient: extend eos metadata with atime/ctime

* fix variable

* handle conv err
  • Loading branch information
labkode authored and gmgigi96 committed Jun 28, 2023
1 parent ce2ee63 commit f18c8f0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog/unreleased/extend-eos-meta.md
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit f18c8f0

Please sign in to comment.