update nodeRestoreExtendedAttributes() for win

- also other platforms
- move xattr include/exclude filter parsing into
  separate func

Signed-off-by: Tesshu Flower <tflower@redhat.com>
This commit is contained in:
Tesshu Flower
2025-01-10 15:13:44 -05:00
parent af839f9548
commit f457b16b23
7 changed files with 62 additions and 46 deletions
+11 -6
View File
@@ -69,15 +69,20 @@ func utimesNano(path string, atime, mtime int64, _ restic.NodeType) error {
}
// restore extended attributes for windows
func nodeRestoreExtendedAttributes(node *restic.Node, path string) (err error) {
func nodeRestoreExtendedAttributes(node *restic.Node, path string, xattrSelectFilter func(xattrName string) bool) error {
count := len(node.ExtendedAttributes)
if count > 0 {
eas := make([]extendedAttribute, count)
for i, attr := range node.ExtendedAttributes {
eas[i] = extendedAttribute{Name: attr.Name, Value: attr.Value}
eas := []extendedAttribute{}
for _, attr := range node.ExtendedAttributes {
// Filter for xattrs we want to include/exclude
if xattrSelectFilter(attr.Name) {
eas = append(eas, extendedAttribute{Name: attr.Name, Value: attr.Value})
}
}
if errExt := restoreExtendedAttributes(node.Type, path, eas); errExt != nil {
return errExt
if len(eas) > 0 {
if errExt := restoreExtendedAttributes(node.Type, path, eas); errExt != nil {
return errExt
}
}
}
return nil