Skip to content

FileProvider macOS xcode13.0 beta2

Manuel de la Pena edited this page Jul 29, 2021 · 3 revisions

#FileProvider.framework https://github.com/xamarin/xamarin-macios/pull/12300

diff -ruN /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h /Applications/Xcode_13.0.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h
--- /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h	2021-06-02 12:47:29.000000000 -0400
+++ /Applications/Xcode_13.0.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h	2021-06-22 17:34:09.000000000 -0400
@@ -163,6 +163,25 @@
  */
 @property (readwrite, assign) NSFileProviderDomainTestingModes testingModes FILEPROVIDER_API_AVAILABILITY_V3_1;
 
+/**
+ Identity of the backing store of the domain on the system.
+
+ This property only applies for extension that implement NSFileProviderReplicatedExtension.
+
+ This provides an identifier that uniquely identifies the backing store used by the system for
+ the domain. When this identifier has changed, the system has dropped its backing store and is
+ building a new one.
+
+ The system may decide to rebuild its backing store if it got corrupted. The provider can also
+ cause the backing store to be rebuilt by calling
+ `-[NSFileProviderManager reimportItemsBelowItemWithIdentifier:completionHandler:]`.
+
+ When rebuilding the backing store, the system will invalidate any extension instance associated
+ to that domain. As a consequence, the identity of the backing store is guaranteed to be stable
+ for the lifetime of the NSFileProviderReplicatedExtension instance.
+ */
+@property (nonatomic, readonly, nullable) NSData *backingStoreIdentity FILEPROVIDER_API_AVAILABILITY_V4_0;
+
 @end
 
 FILEPROVIDER_API_AVAILABILITY_V2
diff -ruN /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderItem.h /Applications/Xcode_13.0.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderItem.h
--- /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderItem.h	2021-06-02 12:44:31.000000000 -0400
+++ /Applications/Xcode_13.0.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderItem.h	2021-06-22 17:34:09.000000000 -0400
@@ -525,7 +525,7 @@
   - `NSFileProviderUserInteractions` *array*
     - `ActivationRule ` *string*, the predicate.
         @parameters predicates
-            - `destinationItem`: the destination item for an action (only present for Move/Import)
+            - `destinationItem`: the destination item for an action. Present for Move/MoveIn/Copy/CopyIn/Create
             - `action` : the action that is being performed
                  'Move'       : moving item(s) within the same provider
                  'MoveOut'    : moving item(s) out of the provider
@@ -543,9 +543,12 @@
                             The destinationItem is the directory which the file/folder is being created
                             within.
                  'Delete'     : deleting item(s)
+                             If the provider wishes to take full responsibility for showing warnings on Delete,
+                             the provider can set NSExtensionFileProviderAllowsSystemDeleteAlerts=0 in the provider's Info.plist.
+                             This will ensure that the system does not display it's warnings when the user is deleting a file.
                  'ExcludeFromSync' : deleting items(s) because the user chose to exclude those from sync (available in macOS 11.3 and later)
                  'Rename'  : renaming item(s) (available in macOS 11.3 and later)
-            - `sourceItem` : current item that the predicate is evaluating
+            - `sourceItem` : current item that the predicate is evaluating. Present for Move/MoveOut/Copy/CopyOut/Create/Trash/Delete/ExcludeFromSync/Rename
             - `sourceItemsCount` :
                 - In userInteraction, represents the count of sourceItems of an action operation
                 - In subUserInteraction: represents the count of items that matched the previous predicate
@@ -566,7 +569,8 @@
             - `Continue` *bool*, the boolean for whether to have a continue button - default value is YES if not specified
             - `Destructive` *bool*, the boolean for whether continuing is a destructive action - default value is NO if not specified
     - `HelpURL` *string*: If present, a help button will be displayed on the Alert that is shown. If the user
-                   clicks the help button, this help URL will be opened. (available in macOS 12.0 and later)
+                   clicks the help button, this help URL will be opened. This URL is not restricted to Web URLs. For instance, the extension could configure
+                   the HelpURL to launch it's application with a custom URL scheme. (available in macOS 12.0 and later)
     - `SubInteractions `: *dictionary* (same as `NSFileProviderUserInteractions`)
     - `SupressionIdentifier` *string*: If present, when this predicate matches, the alert will display an option to
                            suppress future alerts from UserInteractions with the same
diff -ruN /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderManager.h /Applications/Xcode_13.0.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderManager.h
--- /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderManager.h	2021-06-02 12:44:31.000000000 -0400
+++ /Applications/Xcode_13.0.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderManager.h	2021-06-17 14:34:04.000000000 -0400
@@ -203,6 +203,13 @@
 
 /**
  Register a domain in which items can be stored.
+
+ If a domain with the same identifier already exists, `addDomain` will update the display name
+ and hidden state of the domain and succeed.
+
+ When the domain is backed by a NSFileProviderReplicatedExtension, the system will create
+ a disk location where the domain will be replicated. If that location already exists on disk
+ this call will fail with the code NSFileWriteFileExistsError.
  */
 + (void)addDomain:(NSFileProviderDomain *)domain completionHandler:(void(^)(NSError *_Nullable error))completionHandler;
 
diff -ruN /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderReplicatedExtension.h /Applications/Xcode_13.0.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderReplicatedExtension.h
--- /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderReplicatedExtension.h	2021-05-22 08:31:34.000000000 -0400
+++ /Applications/Xcode_13.0.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderReplicatedExtension.h	2021-06-17 01:28:17.000000000 -0400
@@ -207,6 +207,26 @@
  The provider can notify the system of changes on the items by publishing those on the
  enumerator for the working set. The system notifies the extension of changes made by the
  user on disk by calling createItemBasedOnTemplate, modifyItem, or deleteItemWithIdentifier.
+
+ Concurrency:
+ ------------
+ A replicated extension class must be prepared to handle multiple concurrent calls since the
+ system may perform several concurrent operations (for instance, modifying an item, while enumerating
+ the working set, creating another item, and fetching the contents of yet another item).
+
+ The system has limits to the number of concurrent operations.When the number of concurrent
+ operations is reached, the system will not schedule additional operations falling in that category
+ until at least one of the running operation has completed by calling its completion handler.
+
+ The system currently separates the operations into the following categories:
+ - enumeration of the working set. At most 1 enumeration of the working set can happen at a given time
+ - downloads. The system has a limit on the number of concurrent calls to fetchContents and similar calls
+   That limit is configurable by setting the NSExtensionFileProviderDownloadPipelineDepth key to an integer
+   value (between 1 and 128) in the Info.plist of the extension.
+ - uploads. The system has a limit on the number of concurrent calls to createItemBasedOnTemplate and
+   modifyItem when the call includes new content to be uploaded. That limit is configurable by setting the
+   NSExtensionFileProviderUploadPipelineDepth key to an integer value (between 1 and 128) in the Info.plist
+   of the extension.
  */
 FILEPROVIDER_API_AVAILABILITY_V3
 @protocol NSFileProviderReplicatedExtension <NSObject, NSFileProviderEnumerating>
@@ -557,6 +577,23 @@
  but direct file system changes (e.g. from Terminal) can still result in changes that
  must be handled.
 
+ Conflict resolution:
+ -------------------
+ The system passes a `baseVersion` parameter to the modifyItem call. This
+ baseVersion describes the latest version of the file which was reflected on disk.
+ This parameter can be used to detect conflicts with remote edits.
+
+ For instance, if content version A of the file was downloaded to the local system, and
+ the content was modified locally, the modifyItem call will receive baseVersion of A. If the server
+ has in the meantime received another content edit of the same file, the server may
+ have content version C. In this case, the extension can detect the mismatching baseVersion,
+ and decide how to resolve the conflict. The extension informs the system of how it
+ wishes to resolve the conflict by returning the resolved metadata on the completion handler.
+ As an example resolution, if the extension informs that it wishes for the remote version
+ of the item to be on disk (and to ignore the local edits), it should return the new
+ contentVersion in the completion handler's item. The system will subsequently call
+ fetchContents to retrieve the new contents and replace them on disk.
+
  Structural consistency and Cycle handling:
  ------------------------------------------
  In case the parentItemIdentifier is modified, the system guarantees that the new
Clone this wiki locally