From e07b242e9b02a501a025f6556f0da57f5f8ba3e4 Mon Sep 17 00:00:00 2001 From: Vladyslav Date: Fri, 26 Jul 2024 16:15:24 +0300 Subject: [PATCH 1/2] Add prefix to the xattr --- common/hash_data_adapter_xattr.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/hash_data_adapter_xattr.go b/common/hash_data_adapter_xattr.go index 990686896..882a4391d 100644 --- a/common/hash_data_adapter_xattr.go +++ b/common/hash_data_adapter_xattr.go @@ -15,6 +15,8 @@ import ( // ===== OS-Specific hash adapter changes ===== +const AzCopyHashXattrName = "user" + AzCopyHashDataStream + func (HashStorageMode) XAttr() HashStorageMode { return 11 } // It's OK if OS-specific options overlap, but we should leave some room for the agnostic options func (e HashStorageMode) osDefault() HashStorageMode { return e.XAttr() } @@ -52,7 +54,7 @@ func (a *XAttrHashDataAdapter) GetHashData(relativePath string) (*SyncHashData, buf := make([]byte, 512) // 512 bytes should be plenty of space retry: - sz, err := unix.Getxattr(metaFile, strings.TrimPrefix(AzCopyHashDataStream, "."), buf) // MacOS doesn't take well to the dot(?) + sz, err := unix.Getxattr(metaFile, AzCopyHashXattrName, buf) // MacOS doesn't take well to the dot(?) if err != nil { if err == unix.ERANGE { // But just in case, let's safeguard against it and re-call with a larger buffer. buf = make([]byte, len(buf) * 2) @@ -89,7 +91,7 @@ func (a *XAttrHashDataAdapter) SetHashData(relativePath string, data *SyncHashDa return fmt.Errorf("failed to marshal xattr: %w", err) } - err = unix.Setxattr(metaFile, strings.TrimPrefix(AzCopyHashDataStream, "."), buf, 0) // Default flags == create or replace + err = unix.Setxattr(metaFile, AzCopyHashXattrName, buf, 0) // Default flags == create or replace if err != nil { return fmt.Errorf("failed to write xattr: %w; consider utilizing an OS-agnostic hash storage mode", err) } From c1897d78ebe6e7d9a2efb617b9af032f854592e9 Mon Sep 17 00:00:00 2001 From: Vladyslav Date: Sat, 27 Jul 2024 18:39:58 +0300 Subject: [PATCH 2/2] Remove unused import --- common/hash_data_adapter_xattr.go | 1 - 1 file changed, 1 deletion(-) diff --git a/common/hash_data_adapter_xattr.go b/common/hash_data_adapter_xattr.go index 882a4391d..b4a15c9eb 100644 --- a/common/hash_data_adapter_xattr.go +++ b/common/hash_data_adapter_xattr.go @@ -10,7 +10,6 @@ import ( "fmt" "golang.org/x/sys/unix" "path/filepath" - "strings" ) // ===== OS-Specific hash adapter changes =====