2
2
mirror of https://github.com/octoleo/restic.git synced 2024-05-28 22:50:48 +00:00

Continue if extended attribute cannot be read

This commit is contained in:
Alexander Neumann 2017-02-16 14:25:56 +01:00
parent 6df2f9e5ba
commit ef52d15edd
2 changed files with 26 additions and 15 deletions

View File

@ -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 {

View File

@ -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
}