Skip to content

Commit d217886

Browse files
authored
fix xattr error types, remove error wrapper (cs3org#2541)
Signed-off-by: Michael Barz <[email protected]>
1 parent c7e6607 commit d217886

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

changelog/unreleased/decomposedfs-xattr-errors.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Enhancement: Refactored the xattrs package in the decomposedfs
33
The xattrs package now uses the xattr.ENOATTR instead of os.ENODATA or os.ENOATTR to check attribute existence.
44

55
https://github.com/cs3org/reva/pull/2540
6+
https://github.com/cs3org/reva/pull/2541

pkg/storage/utils/decomposedfs/xattrs/errors.go

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
// granted to it by virtue of its status as an Intergovernmental Organization
1717
// or submit itself to any jurisdiction.
1818

19-
//go:build !darwin
20-
// +build !darwin
21-
2219
package xattrs
2320

2421
import (

pkg/storage/utils/decomposedfs/xattrs/xattrs.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"strings"
2424

2525
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
26-
"github.com/pkg/errors"
2726
"github.com/pkg/xattr"
2827
)
2928

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

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

161160
v, err := xattr.Get(filePath, key)
162161
if err != nil {
163-
return "", errors.Wrap(err, "xattrs: Can not read xattr")
162+
return "", err
164163
}
165164
val := string(v)
166165
return val, nil
@@ -174,7 +173,7 @@ func GetInt64(filePath, key string) (int64, error) {
174173
}
175174
v, err := strconv.ParseInt(attr, 10, 64)
176175
if err != nil {
177-
return 0, errors.Wrapf(err, "invalid xattr format")
176+
return 0, err
178177
}
179178
return v, nil
180179
}
@@ -183,14 +182,14 @@ func GetInt64(filePath, key string) (int64, error) {
183182
func All(filePath string) (map[string]string, error) {
184183
attrNames, err := xattr.List(filePath)
185184
if err != nil {
186-
return nil, errors.Wrap(err, "xattrs: Can not list extended attributes")
185+
return nil, err
187186
}
188187

189188
attribs := make(map[string]string, len(attrNames))
190189
for _, name := range attrNames {
191190
val, err := xattr.Get(filePath, name)
192191
if err != nil {
193-
return nil, errors.Wrap(err, "Failed to read extended attrib")
192+
return nil, err
194193
}
195194
attribs[name] = string(val)
196195
}

0 commit comments

Comments
 (0)