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

add etag to spaces response #2616

Merged
merged 1 commit into from
Mar 4, 2022
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
5 changes: 5 additions & 0 deletions changelog/unreleased/spaces-etags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: add etag to spaces response

Added the spaces etag to the response when listing spaces.

https://github.com/cs3org/reva/pull/2616
12 changes: 12 additions & 0 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,21 +648,33 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node,

// we set the space mtime to the root item mtime
// override the stat mtime with a tmtime if it is present
var tmtime time.Time
if tmt, err := n.GetTMTime(); err == nil {
tmtime = tmt
un := tmt.UnixNano()
space.Mtime = &types.Timestamp{
Seconds: uint64(un / 1000000000),
Nanos: uint32(un % 1000000000),
}
} else if fi, err := os.Stat(nodePath); err == nil {
// fall back to stat mtime
tmtime = fi.ModTime()
un := fi.ModTime().UnixNano()
space.Mtime = &types.Timestamp{
Seconds: uint64(un / 1000000000),
Nanos: uint32(un % 1000000000),
}
}

etag, err := node.CalculateEtag(n.ID, tmtime)
if err != nil {
return nil, err
}
space.Opaque.Map["etag"] = &types.OpaqueEntry{
Decoder: "plain",
Value: []byte(etag),
}

spaceAttributes, err := xattrs.All(nodePath)
if err != nil {
return nil, err
Expand Down