I have a Finder Sync Extension (FSE) which shows statuses of files. Is there a way I can force FSE to again request statuses for all files/folder currently visible in Finder window.
Finder Sync Extension (FSE) has callbacks beginObservingDirectoryAtURL
and endObservingDirectoryAtURL
where you can keep track of what paths are being observed (ie by adding/removing paths to NSMutableSet
).
Also, whenever Main app informs FSE about file sync status update, FSE can cache the received state in dictionary where file path is mapped to file sync status.
Then, when FSE receives a message from the main app to refresh all items, FSE should check what paths are being observed, and then request new statuses from the main app for all cached paths having prefix in observing-set. Additionally, FSE should delete it's internal cache forcing it to request newly observed files from the main app (ie when user opens some other folder).
Once FSE receives the message from the main app, it can invoke the
[[FIFinderSyncController defaultController] setBadgeIdentifier:syncStatus forURL:url]
and thus set the proper sync status icon for the URL.
This solution assumes bidirectional communication channel between FSE and Main app which can be achieved either by using NSDistributedNotificationCenter
or via CFMessagePort
.
Also keep in mind that there can be more than one FSE instance running (ie Save dialog from 3rd app)