2
2
mirror of https://github.com/octoleo/restic.git synced 2024-05-29 07:00:49 +00:00

Correct error check for ENOTSUP, add errors.Wrap()

This commit is contained in:
Alexander Neumann 2017-02-18 11:35:04 +01:00
parent ef52d15edd
commit 132afbe83b
2 changed files with 9 additions and 9 deletions

View File

@ -577,9 +577,8 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error {
case "symlink":
node.LinkTarget, err = fs.Readlink(path)
node.Links = uint64(stat.nlink())
err = errors.Wrap(err, "Readlink")
if err != nil {
return err
return errors.Wrap(err, "Readlink")
}
case "dev":
node.Device = uint64(stat.rdev())
@ -597,7 +596,7 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error {
return err
}
return err
return nil
}
func (node *Node) fillExtendedAttributes(path string) error {

View File

@ -4,6 +4,7 @@
package restic
import (
"restic/errors"
"syscall"
"github.com/pkg/xattr"
@ -12,27 +13,27 @@ import (
// Getxattr retrieves extended attribute data associated with path.
func Getxattr(path, name string) ([]byte, error) {
b, e := xattr.Getxattr(path, name)
if e == syscall.ENOTSUP {
if err, ok := e.(*xattr.XAttrError); ok && err.Err == syscall.ENOTSUP {
return nil, nil
}
return b, e
return b, errors.Wrap(e, "Getxattr")
}
// 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.Listxattr(path)
if e == syscall.ENOTSUP {
if err, ok := e.(*xattr.XAttrError); ok && err.Err == syscall.ENOTSUP {
return nil, nil
}
return s, e
return s, errors.Wrap(e, "Listxattr")
}
// Setxattr associates name and data together as an attribute of path.
func Setxattr(path, name string, data []byte) error {
e := xattr.Setxattr(path, name, data)
if e == syscall.ENOTSUP {
if err, ok := e.(*xattr.XAttrError); ok && err.Err == syscall.ENOTSUP {
return nil
}
return e
return errors.Wrap(e, "Setxattr")
}