Skip to content

Commit

Permalink
Add prefix to the xattr
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvietOK committed Jul 26, 2024
1 parent 0254a7e commit d97c1e7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions common/hash_data_adapter_xattr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit d97c1e7

Please sign in to comment.