Why is fetchContents() called when opening an already materialized file?

I am implementing a file provider based on NSFileProviderReplicatedExtension on macOS. Currently I am working on the download of remote dataless files which works fine so far. It is materialized and available locally and the related NSFileProviderItem object I provide to the system returns true for isDownloaded and isMostRecentVersionDownloaded.

When I open the plain text file in Finder in TextEdit, then it is actually opened by the app but almost immediately the system also calls fetchContents(...) on my extension object. I do not understand why because there is no need to fetch the contents.

I tried various ways to call the mandatory completion handler of fetchContents(...), but apparently either a URL to a local content file and the NSFileProviderItem have to be provided or an Error.

Note: When opening the plain text file through Finder in TextEdit the modifyItem(...) function on my file provider extension is called, too, to update the .lastUsedDate. In that completion handler I provide false as the argument which tells the system to request the item contents.

How can I make clear that the system should not call fetchContents(...) for already downloaded files over and over again?

Answered by Engineer in 736830022

Are you returning the same -[NSFileProviderItem contentVersion] on the modifyItem completion handler, as you had previously returned for the same item ?

Please do file a feedback if you feel the behavior is incorrect. Please install the iCloud Drive logging profile [1], reboot, reproduce, and then take a sysdiagnose to attach to the feedback. (And note the timestamp of your reproduction).

1: https://developer.apple.com/bug-reporting/profiles-and-logs/?platform=macos&name=drive

Accepted Answer

Are you returning the same -[NSFileProviderItem contentVersion] on the modifyItem completion handler, as you had previously returned for the same item ?

Please do file a feedback if you feel the behavior is incorrect. Please install the iCloud Drive logging profile [1], reboot, reproduce, and then take a sysdiagnose to attach to the feedback. (And note the timestamp of your reproduction).

1: https://developer.apple.com/bug-reporting/profiles-and-logs/?platform=macos&name=drive

Why is fetchContents() called when opening an already materialized file?
 
 
Q