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

eosclient: extend eos metadata with atime/ctime #3954

Merged
merged 3 commits into from
Jun 8, 2023
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
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