data: split node and snapshot code from restic package

This commit is contained in:
Michael Eischer
2025-09-23 20:01:09 +02:00
parent c85b157e0e
commit 56ac8360c7
166 changed files with 1170 additions and 1107 deletions

View File

@@ -7,9 +7,9 @@ import (
"os"
"syscall"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic"
"github.com/pkg/xattr"
)
@@ -63,7 +63,7 @@ func handleXattrErr(err error) error {
}
}
func nodeRestoreExtendedAttributes(node *restic.Node, path string, xattrSelectFilter func(xattrName string) bool) error {
func nodeRestoreExtendedAttributes(node *data.Node, path string, xattrSelectFilter func(xattrName string) bool) error {
expectedAttrs := map[string]struct{}{}
for _, attr := range node.ExtendedAttributes {
// Only restore xattrs that match the filter
@@ -96,7 +96,7 @@ func nodeRestoreExtendedAttributes(node *restic.Node, path string, xattrSelectFi
return nil
}
func nodeFillExtendedAttributes(node *restic.Node, path string, ignoreListError bool, warnf func(format string, args ...any)) error {
func nodeFillExtendedAttributes(node *data.Node, path string, ignoreListError bool, warnf func(format string, args ...any)) error {
xattrs, err := listxattr(path)
debug.Log("fillExtendedAttributes(%v) %v %v", path, xattrs, err)
if err != nil {
@@ -106,14 +106,14 @@ func nodeFillExtendedAttributes(node *restic.Node, path string, ignoreListError
return err
}
node.ExtendedAttributes = make([]restic.ExtendedAttribute, 0, len(xattrs))
node.ExtendedAttributes = make([]data.ExtendedAttribute, 0, len(xattrs))
for _, attr := range xattrs {
attrVal, err := getxattr(path, attr)
if err != nil {
warnf("can not obtain extended attribute %v for %v:\n", attr, path)
continue
}
attr := restic.ExtendedAttribute{
attr := data.ExtendedAttribute{
Name: attr,
Value: attrVal,
}