We are implementing a file system extension using the file provider replicated extension for an application on Mac OS. On part of it, we need to show context menus for items(files/folders) inside the file provider's mounted folder.
But we don't want to show the context menu based on the 'activation rule' key's value declared on each NSExtensionFileProviderActions item in the info.plist file but with the main app's code logic. Because if we use the info.plist activation rule, we need to use each item's instance variables as part of predicate query(which decides on showing the context menu item), and after performing the action, we need to change the value of that instance variable so that we can show opposite context menu of the previous one (for example if previously 'set offline' is clicked, now 'set online' have to be shown) but doing this is tedious process.
Also, we already implemented the code logic in our main app(that is not written in swift) to choose what are the context menu items to be shown and so we want to use it.
So, Instead, we are hoping to do it either:
By handling the get-menu function call or
By handling the predicate checking function call.
Kindly let us know if is there any function we can override or inform the system to do at least any one of the above things.
Thanks in advance.
Post
Replies
Boosts
Views
Activity
Currently, we are doing it by:
Calling the function 'signalEnumerator' with the identifier as workingset
Returning the metas of the new changes to the function enumerateChanges called by the file provider
Sometimes, it would take more time to get the enumerateChanges function call from the file provider after invoking the signalEnumerator function. So, Kindly let us know if is there any other alternative to pass the new updated items information to the file provider properly and quickly.
Previously, we are using the Finder Sync extension for showing the context menu on the finder items. But now we are planning to use the File Provider extension on Mac OS.
So, as of our learning, we found that the context menu items to be shown on the finder items have to be informed using the 'NSExtensionFileProviderActions' key in the info.plist file and the activation rule also have to be informed there under key 'NSExtensionFileProviderActionActivationRule'.
But in the Finder Sync, we can get both the right-click(to list menu) and menu item clicked(on the context menu shown) calls from the Finder Sync extension.
Like Finder Sync Extension, can we able to get both the calls from the file provider extension?
Our application which isn't a sandboxed app tries to access(copies) the file from the URL given by the file provider to the application's cache path but fails with the 'operation not permitted' error. This happens in two cases 1. File Creation & 2. File Modification.
Also, on checking the path, it is like "/Library/Application Support/FileProvider/{RandID}/wharf/wharf/propagate".
Even we tried to access the folder using a Python script and run it via the terminal but it also failed with the same error.
But when we enable the 'full disk access' option in the 'privacy & security' tab of the system settings for the application(our main app/terminal), the files can be accessed.
Our application doesn't need the 'full disk access' instead it needs permission to access the file provider extension's cache path where the temp files were stored.
How to get permissions for that folder and access the files (like setting the entitlement keys or other ways)? Or else
Is there any way to inform the system to use our application cache path as the file provider's cache path?
Any help would be appreciated.
For a new file creation, we need to throw NSFileProviderError(.cannotSynchronize) but we need the file provider to use our identifier instead of the file provider's default identifier (Say 'fp_{RandomID}').
So, we tried giving the NSFileProviderItem object created with our identifier in the completion handler of the createItem function and set the error field with NSFileProviderError(.cannotSynchronize).
But this would create another item in the finder with a name suffixed with '2'(Say 'FileName 2') but the temporary File Provider Identifier and the filename(Say 'FileName') of this NSFileProviderItem object are the same as the previous one. Only the finder and the URL fetched using FileManager.getUserVisibleURL function shows 'FileName 2'.
Why is this behaviour happening?
Why can't the file provider use the identifier given by the main app?
What is the proper way to throw an error in the createItem function but to use the given custom identifier for the item instead of the FP default identifier so that the FP should use the custom identifier in future references?
Thanks.
We use File Provider Extension in our main app, and it is working fine.
We always call "NSFileProviderManager.add(_:completionHandler:)" function to start the extension, and "NSFileProviderManager.disconnect(reason:options:completionHandler:)" to temporarily quit the extension with the reason which will be shown in the Finder at the top of the FP domain folder.
But sometimes, when the main app calls the above functions, the following issue cases occur, and the extension does not start/stop:
The completionHandler function doesn't get called (As we noticed, we waited for 2 minutes. Then, we restarted the main app.)
One of the following errors returned: i) "The application cannot be used right now", ii) "Couldn't communicate with the helper application", iii) "No valid file provider found with identifier"
Here, the important thing is that restarting the main app once or twice clears the issue, and the extension starts.
But it is frustrating to restart the app each time we get this issue.
We want to know the following things:
Why and when do the above issues occur?
Why do they occur only sometimes, and how does the app restart clear the issue?
How do we resolve them without restarting the main app?
This has become a critical issue, so a detailed explanation would be greatly appreciated. TIA.