Skip to content

Commit

Permalink
Use github.com/pkg/xattr for reading/writing extended attributes.
Browse files Browse the repository at this point in the history
The one previously used, github.com/redsift/xattr, is old and can only process
user-defined extended attributes, not system ones.
  • Loading branch information
gilbertchen committed Oct 17, 2020
1 parent 7c36311 commit b392302
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/duplicacy_utils_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"path/filepath"
"syscall"

"github.com/gilbertchen/xattr"
"github.com/pkg/xattr"
)

func Readlink(path string) (isRegular bool, s string, err error) {
Expand Down Expand Up @@ -50,11 +50,11 @@ func SetOwner(fullPath string, entry *Entry, fileInfo *os.FileInfo) bool {
func (entry *Entry) ReadAttributes(top string) {

fullPath := filepath.Join(top, entry.Path)
attributes, _ := xattr.Listxattr(fullPath)
attributes, _ := xattr.List(fullPath)
if len(attributes) > 0 {
entry.Attributes = make(map[string][]byte)
for _, name := range attributes {
attribute, err := xattr.Getxattr(fullPath, name)
attribute, err := xattr.Get(fullPath, name)
if err == nil {
entry.Attributes[name] = attribute
}
Expand All @@ -63,24 +63,25 @@ func (entry *Entry) ReadAttributes(top string) {
}

func (entry *Entry) SetAttributesToFile(fullPath string) {
names, _ := xattr.Listxattr(fullPath)
names, _ := xattr.List(fullPath)

for _, name := range names {


newAttribute, found := entry.Attributes[name]
if found {
oldAttribute, _ := xattr.Getxattr(fullPath, name)
oldAttribute, _ := xattr.Get(fullPath, name)
if !bytes.Equal(oldAttribute, newAttribute) {
xattr.Setxattr(fullPath, name, newAttribute)
xattr.Set(fullPath, name, newAttribute)
}
delete(entry.Attributes, name)
} else {
xattr.Removexattr(fullPath, name)
xattr.Remove(fullPath, name)
}
}

for name, attribute := range entry.Attributes {
xattr.Setxattr(fullPath, name, attribute)
xattr.Set(fullPath, name, attribute)
}

}
Expand Down

3 comments on commit b392302

@gilbertchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Duplicacy Forum. There might be relevant details there:

https://forum.duplicacy.com/t/qnap-files-restored-to-a-new-location-are-inaccessible/4350/3

@gilbertchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Duplicacy Forum. There might be relevant details there:

https://forum.duplicacy.com/t/cli-2-7-2-is-now-available/4483/1

@gilbertchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Duplicacy Forum. There might be relevant details there:

https://forum.duplicacy.com/t/xfs-corruption-on-restore-extended-attributes/5548/2

Please sign in to comment.