File edited by WPS Office can't be detected by FileProviderExtension on macOS

This seems to be a bug in the macOS FileProvider framework.

Repro steps:

  1. Open a file in the File Provider domain and edit it using WPS Office
  2. Save the file in WPS and close the editor tab or WPS Office window
  3. The file in the File Provider domain shows an uploading icon, and the modifyItem(_:baseVersion:changedFields:contents:options:request:completionHandler:) callback will never be triggered, so the file won’t be uploaded, and will always shows an "uploading" icon

I investigated the issue and found out that the root cause seems to be related to flock, In step 2, after saving the changes, the file is still exclusively locked by WPS Office, In the log of fileproviderd there is an error saying "itemIsFlockedCanNotPropagate", this is understandable since the file is exclusively flocked, and fileproviderd couldn’t propagate the item and trigger the modifyItem callback,

What I'm struggling with is that after the file is closed, or even after the WPS Office app has been quit, the modifyItem callback still won’t be fired by the system.

What’s even more interesting is that at this time if you manually invoke flock(fd, LOCK_UN) for the file, the modifyItem callback will be triggered right away. In other words, it seems to me that fileproviderd is monitoring the unlock signal of the file descriptor, if a file is flocked with flock(fd, LOCK_EX) and then closed without invoking flock(fd, LOCK_UN), fileproviderd will not able to propagate the change and the modifyItem callback will never be triggered, then FileProviderExtension or the App won’t know that file is changed, the file will always shows an “uploading” icon in Finder.

I've tested this against the official FruitBusket sample, OneDrive, Box-Drive and Dropxbox, they all implemented the NSFileProviderReplicatedExtension, and all have the same issue.

Replies

@clenart Hi. please see if there is any solution to this problem. WPS Office