'How to force macOS File Provider Extension to re-enumerate items

Is there a way to force macOS File Provider Extension to re-enumerate items for given parent container?

I am aware that we can signalEnumerator(for: .workingSet) but that would just invoke the enumerateChanges callback in FileProviderEnumerator. What I'm looking for is something like: Internal structure changed so much, that it would be best to re-enumerate the content and rebuild the new model with it. And that should result in invoking the enumerateItems callback in the FileProviderEnumerator.

Are there any options to achieving just that?



Solution 1:[1]

Maybe deregistering and registering FileProvider domain could help.

To remove all domains and add domain again:

let identifier = NSFileProviderDomainIdentifier(rawValue: "Your-Domain-Identifier")
let domain = NSFileProviderDomain(identifier: identifier, displayName: "Your-Provider-Domain")

NSFileProviderManager.removeAllDomains { error in
    if error != nil {
        print("Error removing all domains: \(error)")
    } else {
        NSFileProviderManager.add(domain) { error in
            print("Error adding domain: \(error)")
        }
    }
}

This should result in re-fetching (enumerating) root container again and all its children as user browses content in Finder.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mixtly87