Enlarging the working set is straightforward — every item returned from enumerateItems(for:startingAt:) becomes part of it. But how do we safely remove items? If we exclude a folder from working-set change enumeration, the system shows the user an obsolete version of that folder, because it never calls enumerateItems(for:startingAt:) for it again. (Note: It seems system does call enumerateItems(for:startingAt:) again for materialized folders after extension restart.)
What's the intended way to evict items from the working set?
Hello,
your question is how to remove items from the working set, while still showing updates locally for those items on user access. For this you can
- evict the folder on disk with
evictItem(withIdentifier:completionHandler:)and after the eviction you can remove the children form the working set as they are not on disk anymore. Note that eviction can fail, so you should check for its success before removing the items from the working set. - or in Finder/Files when the folder is visible in the UI we call
enumerator(for:request). With this you can know when a folder is in use by the user and prioritise the changes in the working set accordingly.
Note that once you remove items from the working set they are not searchable anymore, you will need to adopt NSFileProviderSearching protocol to be able to search them directly on server.