diff --git a/src/restic/node.go b/src/restic/node.go index 1512848c8..5e7e35a1f 100644 --- a/src/restic/node.go +++ b/src/restic/node.go @@ -604,19 +604,29 @@ func (node *Node) fillExtendedAttributes(path string) error { if node.Type == "symlink" { return nil } + xattrs, err := Listxattr(path) - if err == nil { - node.ExtendedAttributes = make([]ExtendedAttribute, len(xattrs)) - for i, attr := range xattrs { - attrVal, err := Getxattr(path, attr) - if err != nil { - return errors.Errorf("can not obtain extended attribute %v for %v:\n", attr, path) - } - node.ExtendedAttributes[i].Name = attr - node.ExtendedAttributes[i].Value = attrVal - } + debug.Log("fillExtendedAttributes(%v) %v %v", path, xattrs, err) + if err != nil { + return err } - return err + + node.ExtendedAttributes = make([]ExtendedAttribute, 0, len(xattrs)) + for _, attr := range xattrs { + attrVal, err := Getxattr(path, attr) + if err != nil { + fmt.Fprintf(os.Stderr, "can not obtain extended attribute %v for %v:\n", attr, path) + continue + } + attr := ExtendedAttribute{ + Name: attr, + Value: attrVal, + } + + node.ExtendedAttributes = append(node.ExtendedAttributes, attr) + } + + return nil } type statT interface { diff --git a/src/restic/node_xattr.go b/src/restic/node_xattr.go index 1b5f085d8..ae1c6443f 100644 --- a/src/restic/node_xattr.go +++ b/src/restic/node_xattr.go @@ -4,13 +4,14 @@ package restic import ( - "github.com/ivaxer/go-xattr" "syscall" + + "github.com/pkg/xattr" ) // Getxattr retrieves extended attribute data associated with path. func Getxattr(path, name string) ([]byte, error) { - b, e := xattr.Get(path, name) + b, e := xattr.Getxattr(path, name) if e == syscall.ENOTSUP { return nil, nil } @@ -20,7 +21,7 @@ func Getxattr(path, name string) ([]byte, error) { // Listxattr retrieves a list of names of extended attributes associated with the // given path in the file system. func Listxattr(path string) ([]string, error) { - s, e := xattr.List(path) + s, e := xattr.Listxattr(path) if e == syscall.ENOTSUP { return nil, nil } @@ -29,7 +30,7 @@ func Listxattr(path string) ([]string, error) { // Setxattr associates name and data together as an attribute of path. func Setxattr(path, name string, data []byte) error { - e := xattr.Set(path, name, data) + e := xattr.Setxattr(path, name, data) if e == syscall.ENOTSUP { return nil }