mirror of
https://github.com/rclone/rclone.git
synced 2026-06-10 17:34:30 -04:00
local: fix getXattr returning empty map instead of nil
At least on my macOS Sequoia 15.7.4, the system automatically adds a com.apple.provenance xattr to files created by processes. This xattr lacks the "user." prefix so getXattr filters it out, but the metadata map was already allocated, resulting in an empty non-nil map being returned instead of nil. This caused TestMetadata/Symlink/Xattr and TestMetadata/File/Xattr to fail because they assert the return value is nil when no user xattrs are present. The fix checks if the metadata map is empty after filtering and returns nil if so.
This commit is contained in:
committed by
Nick Craig-Wood
parent
79f42d37ff
commit
d2b5ff8384
@@ -81,6 +81,10 @@ func (o *Object) getXattr() (metadata fs.Metadata, err error) {
|
||||
}
|
||||
metadata[k] = string(v)
|
||||
}
|
||||
// Return nil if all xattrs were filtered out (e.g. com.apple.provenance on macOS)
|
||||
if len(metadata) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return metadata, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user