restore: exclude/include xattrs

For: https://github.com/restic/restic/issues/5089

Signed-off-by: Tesshu Flower <tflower@redhat.com>
This commit is contained in:
Tesshu Flower
2024-11-04 02:14:45 -05:00
parent e6f9cfb8c8
commit af839f9548
6 changed files with 70 additions and 21 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/test"
rtest "github.com/restic/restic/internal/test"
)
@@ -216,7 +217,8 @@ func TestNodeRestoreAt(t *testing.T) {
nodePath = filepath.Join(tempdir, test.Name)
}
rtest.OK(t, NodeCreateAt(&test, nodePath))
rtest.OK(t, NodeRestoreMetadata(&test, nodePath, func(msg string) { rtest.OK(t, fmt.Errorf("Warning triggered for path: %s: %s", nodePath, msg)) }))
rtest.OK(t, NodeRestoreMetadata(&test, nodePath, func(msg string) { rtest.OK(t, fmt.Errorf("Warning triggered for path: %s: %s", nodePath, msg)) },
func(_ string) bool { return true } /* restore all xattrs */))
fs := &Local{}
meta, err := fs.OpenFile(nodePath, O_NOFOLLOW, true)
@@ -291,6 +293,7 @@ func TestNodeRestoreMetadataError(t *testing.T) {
nodePath := filepath.Join(tempdir, node.Name)
// This will fail because the target file does not exist
err := NodeRestoreMetadata(node, nodePath, func(msg string) { rtest.OK(t, fmt.Errorf("Warning triggered for path: %s: %s", nodePath, msg)) })
rtest.Assert(t, errors.Is(err, os.ErrNotExist), "failed for an unexpected reason")
err := NodeRestoreMetadata(node, nodePath, func(msg string) { rtest.OK(t, fmt.Errorf("Warning triggered for path: %s: %s", nodePath, msg)) },
func(_ string) bool { return true })
test.Assert(t, errors.Is(err, os.ErrNotExist), "failed for an unexpected reason")
}