How can I access the download status of an NSFileProviderItem from the File Provider extension?

When capturing materialized information from materializedItemsDidChange in NSFileProviderReplicatedExtension, the isDownloaded property of NSFileProviderItem is not set during the call to enumerate items (NSFileProviderEnumerationObserver:enumerateItems(for:startingAt:)).

Both the IsDownloaded and isMostRecentVersionDownloaded properties are returning false, even though the item is fully materialized

How to capture this information from file provider extension ?

Any help would be greatly appreciated. Thanks!

Answered by DTS Engineer in 802590022

Yeah, I see the same thing – If I use the enumerator returned by fileProviderManager.enumeratorForMaterializedItems() to enumerate the materialized items, the item.isDownloaded is false.

That is probably just because the enumerator doesn't maintain the isDownloaded state, and isn't really a problem, because the enumeration does return the materialized items.

If you are interested in the pending items, observe the .fileProviderPendingSetDidChange notification, and then in the notification handler, use the same way to retrieve the enumerator (by calling fileProviderManager.enumeratorForMaterializedItems()) and do the enumeration. The items you get would be the pending items.

Our Synchronizing files using file provider extensions demonstrates how to retrieve the materialized and pending items in great details. You might want to take a look, if haven't yet. The details are in EnumerationView (./common/EnumerationView.swift).

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Yeah, I see the same thing – If I use the enumerator returned by fileProviderManager.enumeratorForMaterializedItems() to enumerate the materialized items, the item.isDownloaded is false.

That is probably just because the enumerator doesn't maintain the isDownloaded state, and isn't really a problem, because the enumeration does return the materialized items.

If you are interested in the pending items, observe the .fileProviderPendingSetDidChange notification, and then in the notification handler, use the same way to retrieve the enumerator (by calling fileProviderManager.enumeratorForMaterializedItems()) and do the enumeration. The items you get would be the pending items.

Our Synchronizing files using file provider extensions demonstrates how to retrieve the materialized and pending items in great details. You might want to take a look, if haven't yet. The details are in EnumerationView (./common/EnumerationView.swift).

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

A few follow-up questions:

  1. Materialized items will not include sparse files(partially downloaded). Is there a way to list such files ?

  2. isRecursivelyDownloaded of sourceItem or destinationItem - Does this apply only to folders ?

  3. DomainRemovalMode.preserveDownloadedUserData -Materialized items retain file attributes upon unmounting. How can I change read-only items to read-write?

    NSFileProviderReplicatedExtension.invalidate -> NSFileProviderManager.signalEnumerator(for:) -> NSFileProviderItem.capabilities

    Is it possible to trigger signalEnumerator on invalidate to change the file attribute state just before domain removal ?

How can I access the download status of an NSFileProviderItem from the File Provider extension?
 
 
Q