Extended Attributes in File Provider Extension

I am developing a File Provider Extension on Mac. I am confused about how the extendedAttributes property works. The property never seems to be populated with any extended attributes.

I've tried setting some custom extended attributes on my documents in testing, but they are never populated in the itemTemplates that are produced in the extension. The dictionary that would hold the extended attributes always is empty.

I began to think that it only supported Mac-created attributes such as com.apple.quarantine.

I then tried importing some files that are 'quarantined' with this appropriate extended attribute but still have not seen this data appear in my extension either.

Any clarity here with what I should be expecting or what I should try would be helpful.

Accepted Reply

FileProvider syncs extended attributes with the XATTR_FLAG_SYNCABLE property set.

See xattr_flags.h: https://opensource.apple.com/source/copyfile/copyfile-146/xattr_flags.h.auto.html

Specifically, xattr_name_with_flags for how to construct extended attribute names with the XATTR_FLAG_SYNCABLE property.

In practice it is appending #S to the name of the extended attribute. In your application, you should always use the method in xattr_flags.h to manipulate extended attribute names.

You can use xattr_preserve_for_intent or xattr_flags_from_name to determine whether the system would sync a given extended attribute.

  • To be clear, applications which implement a FileProvider app extension should not read or manipulate xattrs from disk. Those applications should be reading the xattrs from the itemTemplate passed to createItem / modifyItem, and sync those as-is.

    Applications which are writing xattrs to files to store metadata should use xattr_flags.h to construct their xattr names. In order for the system to correctly handle the extended attributes during copy/sync/etc.

  • Wonderful answer. I tested this out and it populates 'syncable' xattrs. Thank you.

Add a Comment

Replies

FileProvider syncs extended attributes with the XATTR_FLAG_SYNCABLE property set.

See xattr_flags.h: https://opensource.apple.com/source/copyfile/copyfile-146/xattr_flags.h.auto.html

Specifically, xattr_name_with_flags for how to construct extended attribute names with the XATTR_FLAG_SYNCABLE property.

In practice it is appending #S to the name of the extended attribute. In your application, you should always use the method in xattr_flags.h to manipulate extended attribute names.

You can use xattr_preserve_for_intent or xattr_flags_from_name to determine whether the system would sync a given extended attribute.

  • To be clear, applications which implement a FileProvider app extension should not read or manipulate xattrs from disk. Those applications should be reading the xattrs from the itemTemplate passed to createItem / modifyItem, and sync those as-is.

    Applications which are writing xattrs to files to store metadata should use xattr_flags.h to construct their xattr names. In order for the system to correctly handle the extended attributes during copy/sync/etc.

  • Wonderful answer. I tested this out and it populates 'syncable' xattrs. Thank you.

Add a Comment