From 9df52327cc79231350c18607472f5c19248436b0 Mon Sep 17 00:00:00 2001 From: hoyho Date: Tue, 10 Nov 2020 00:20:34 +0800 Subject: [PATCH] bugfix: omit ENOTDATA for extended attributes Signed-off-by: hoyho --- changelog/unreleased/issue-1800 | 8 ++++++++ internal/restic/node_xattr.go | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/issue-1800 diff --git a/changelog/unreleased/issue-1800 b/changelog/unreleased/issue-1800 new file mode 100644 index 000000000..be98ac23e --- /dev/null +++ b/changelog/unreleased/issue-1800 @@ -0,0 +1,8 @@ +Bugfix: Ignore 'no data available' error during backup + +restic failed to backup files on some filesystems, for example certain configurations +of CIFS on Linux, which return a "no data available" error when reading extended +attributes. These errors are now ignored. + +https://github.com/restic/restic/issues/1800 +https://github.com/restic/restic/pull/3034 diff --git a/internal/restic/node_xattr.go b/internal/restic/node_xattr.go index ea5ed8d3a..c95257560 100644 --- a/internal/restic/node_xattr.go +++ b/internal/restic/node_xattr.go @@ -16,7 +16,8 @@ import ( // Getxattr retrieves extended attribute data associated with path. func Getxattr(path, name string) ([]byte, error) { b, e := xattr.Get(path, name) - if err, ok := e.(*xattr.Error); ok && err.Err == syscall.ENOTSUP { + if err, ok := e.(*xattr.Error); ok && + (err.Err == syscall.ENOTSUP || err.Err == xattr.ENOATTR) { return nil, nil } return b, errors.Wrap(e, "Getxattr") @@ -26,7 +27,8 @@ func Getxattr(path, name string) ([]byte, error) { // given path in the file system. func Listxattr(path string) ([]string, error) { s, e := xattr.List(path) - if err, ok := e.(*xattr.Error); ok && err.Err == syscall.ENOTSUP { + if err, ok := e.(*xattr.Error); ok && + (err.Err == syscall.ENOTSUP || err.Err == xattr.ENOATTR) { return nil, nil } return s, errors.Wrap(e, "Listxattr") @@ -35,7 +37,8 @@ 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) - if err, ok := e.(*xattr.Error); ok && err.Err == syscall.ENOTSUP { + if err, ok := e.(*xattr.Error); ok && + (err.Err == syscall.ENOTSUP || err.Err == xattr.ENOATTR) { return nil } return errors.Wrap(e, "Setxattr")