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

fix xattr error types, remove error wrapper #2541

Merged
merged 1 commit into from
Feb 14, 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
1 change: 1 addition & 0 deletions changelog/unreleased/decomposedfs-xattr-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Enhancement: Refactored the xattrs package in the decomposedfs
The xattrs package now uses the xattr.ENOATTR instead of os.ENODATA or os.ENOATTR to check attribute existence.

https://github.com/cs3org/reva/pull/2540
https://github.com/cs3org/reva/pull/2541
3 changes: 0 additions & 3 deletions pkg/storage/utils/decomposedfs/xattrs/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

//go:build !darwin
// +build !darwin

package xattrs

import (
Expand Down
11 changes: 5 additions & 6 deletions pkg/storage/utils/decomposedfs/xattrs/xattrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"strings"

provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/pkg/errors"
"github.com/pkg/xattr"
)

Expand Down Expand Up @@ -137,7 +136,7 @@ func CopyMetadata(s, t string, filter func(attributeName string) bool) error {
func Set(filePath string, key string, val string) error {

if err := xattr.Set(filePath, key, []byte(val)); err != nil {
return errors.Wrap(err, "xattrs: Could not write xtended attribute")
return err
}
return nil
}
Expand All @@ -160,7 +159,7 @@ func Get(filePath, key string) (string, error) {

v, err := xattr.Get(filePath, key)
if err != nil {
return "", errors.Wrap(err, "xattrs: Can not read xattr")
return "", err
}
val := string(v)
return val, nil
Expand All @@ -174,7 +173,7 @@ func GetInt64(filePath, key string) (int64, error) {
}
v, err := strconv.ParseInt(attr, 10, 64)
if err != nil {
return 0, errors.Wrapf(err, "invalid xattr format")
return 0, err
}
return v, nil
}
Expand All @@ -183,14 +182,14 @@ func GetInt64(filePath, key string) (int64, error) {
func All(filePath string) (map[string]string, error) {
attrNames, err := xattr.List(filePath)
if err != nil {
return nil, errors.Wrap(err, "xattrs: Can not list extended attributes")
return nil, err
}

attribs := make(map[string]string, len(attrNames))
for _, name := range attrNames {
val, err := xattr.Get(filePath, name)
if err != nil {
return nil, errors.Wrap(err, "Failed to read extended attrib")
return nil, err
}
attribs[name] = string(val)
}
Expand Down