NSFileProviderReplicatedExtension: Download triggered after upload

Hello,

I have another quick question. I'm using NSFileProviderReplicatedExtension to create a macOS File Provider app to access remote files directly in Finder.

When I copy a file to a remote folder (managed by File Provider) "createItem(basedOn itemTemplate: NSFileProviderItem, fields: NSFileProviderItemFields ....)" is triggered and this is fine.

But immediately after the file is upload fetchContents(for itemIdentifier: NSFileProviderItemIdentifier, version ...)" is also triggered.

Is this expected? Downloading again the file after upload requires some time and it's not the best experience for the user if he is in a hurry. Is there any way to prevent this?

Thank you.

Replies

I had the same issue recently and found the answer within createItem() 🙂 https://developer.apple.com/documentation/fileprovider/nsfileproviderreplicatedextension/3656549-createitem

When you are returning the completionHandler, you'll find a boolean option to fetch the content from remote. Simply returning false will not trigger the fetchContents() anymore.

If you are returning a specific type of error along with the successful completionHandler, there is a chance that you'll trigger fetchContents() again which i assume not to be the case here.