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

eosbinary: do not use version folders for xattrs any longer #4520

Merged
merged 1 commit into from
Mar 22, 2024
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/eos-xattr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: do not use version folders for xattrs in EOS

This was a workaround needed some time ago. We revert now
to the standard behavior, xattrs are stored on the files.

https://github.com/cs3org/reva/pull/4520
62 changes: 7 additions & 55 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,22 +442,12 @@ func (c *Client) getRawFileInfoByPath(ctx context.Context, auth eosclient.Author

func (c *Client) mergeACLsAndAttrsForFiles(ctx context.Context, auth eosclient.Authorization, info *eosclient.FileInfo) *eosclient.FileInfo {
// We need to inherit the ACLs for the parent directory as these are not available for files
// And the attributes from the version folders
if !info.IsDir {
parentInfo, err := c.getRawFileInfoByPath(ctx, auth, path.Dir(info.File))
// Even if this call fails, at least return the current file object
if err == nil {
info.SysACL.Entries = append(info.SysACL.Entries, parentInfo.SysACL.Entries...)
}

// We need to merge attrs set for the version folders, so get those resolved for the current user
versionFolderInfo, err := c.GetFileInfoByPath(ctx, auth, getVersionFolder(info.File))
if err == nil {
info.SysACL.Entries = append(info.SysACL.Entries, versionFolderInfo.SysACL.Entries...)
for k, v := range versionFolderInfo.Attrs {
info.Attrs[k] = v
}
}
}

return info
Expand All @@ -469,23 +459,12 @@ func (c *Client) SetAttr(ctx context.Context, auth eosclient.Authorization, attr
return errors.New("eos: attr is invalid: " + serializeAttribute(attr))
}

var info *eosclient.FileInfo
var err error
// We need to set the attrs on the version folder as they are not persisted across writes
// Except for the sys.eval.useracl attr as EOS uses that to determine if it needs to obey
// the user ACLs set on the file
if !(attr.Type == eosclient.SystemAttr && attr.Key == userACLEvalKey) {
info, err = c.getRawFileInfoByPath(ctx, auth, path)
// Favorites need to be stored per user so handle these separately
if attr.Type == eosclient.UserAttr && attr.Key == favoritesKey {
info, err := c.getRawFileInfoByPath(ctx, auth, path)
if err != nil {
return err
}
if !info.IsDir {
path = getVersionFolder(path)
}
}

// Favorites need to be stored per user so handle these separately
if attr.Type == eosclient.UserAttr && attr.Key == favoritesKey {
return c.handleFavAttr(ctx, auth, attr, recursive, path, info, true)
}
return c.setEOSAttr(ctx, auth, attr, errorIfExists, recursive, path)
Expand Down Expand Up @@ -545,23 +524,13 @@ func (c *Client) UnsetAttr(ctx context.Context, auth eosclient.Authorization, at
return errors.New("eos: attr is invalid: " + serializeAttribute(attr))
}

var info *eosclient.FileInfo
var err error
// We need to set the attrs on the version folder as they are not persisted across writes
// Except for the sys.eval.useracl attr as EOS uses that to determine if it needs to obey
// the user ACLs set on the file
if !(attr.Type == eosclient.SystemAttr && attr.Key == userACLEvalKey) {
info, err = c.getRawFileInfoByPath(ctx, auth, path)
// Favorites need to be stored per user so handle these separately
if attr.Type == eosclient.UserAttr && attr.Key == favoritesKey {
info, err := c.getRawFileInfoByPath(ctx, auth, path)
if err != nil {
return err
}
if !info.IsDir {
path = getVersionFolder(path)
}
}

// Favorites need to be stored per user so handle these separately
if attr.Type == eosclient.UserAttr && attr.Key == favoritesKey {
return c.handleFavAttr(ctx, auth, attr, recursive, path, info, false)
}

Expand All @@ -584,21 +553,12 @@ func (c *Client) UnsetAttr(ctx context.Context, auth eosclient.Authorization, at

// GetAttr returns the attribute specified by key.
func (c *Client) GetAttr(ctx context.Context, auth eosclient.Authorization, key, path string) (*eosclient.Attribute, error) {
// As SetAttr set the attr on the version folder, we will read the attribute on it
// if the resource is not a folder
info, err := c.getRawFileInfoByPath(ctx, auth, path)
if err != nil {
return nil, err
}
if !info.IsDir {
path = getVersionFolder(path)
}

args := []string{"attr", "get", key, path}
attrOut, _, err := c.executeEOS(ctx, args, auth)
if err != nil {
return nil, err
}

attr, err := deserializeAttribute(attrOut)
if err != nil {
return nil, err
Expand All @@ -608,14 +568,6 @@ func (c *Client) GetAttr(ctx context.Context, auth eosclient.Authorization, key,

// GetAttrs returns all the attributes of a resource.
func (c *Client) GetAttrs(ctx context.Context, auth eosclient.Authorization, path string) ([]*eosclient.Attribute, error) {
info, err := c.getRawFileInfoByPath(ctx, auth, path)
if err != nil {
return nil, err
}
if !info.IsDir {
path = getVersionFolder(path)
}

args := []string{"attr", "ls", path}
attrOut, _, err := c.executeEOS(ctx, args, auth)
if err != nil {
Expand Down
Loading