Merge pull request #3034 from hoyho/gh_master

bugfix: omit ENOTDATA for extended attributes
This commit is contained in:
MichaelEischer 2020-11-09 22:38:49 +01:00 committed by GitHub
commit 407843c5f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

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

View File

@ -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")