I have a files provider app that seems to be working perfectly except for one thing. If I have a directory open in the files provider app and then put the app into the backround and while in the background a file is renamed in the open directory via some other app, then when the files app comes back into the foreground it shows the file with the old name as well as the new name.
I can see via logging that the FileproviderEnumerator is being closed when the app is moved to the background and then reopened when it is moved back into the foreground and I can also see that the correct file names are loaded into it when enumerating.
It looks like the files app doesn't check to see if what it currently has in its cache matches what was just loaded and remove anything that is missing.
To make it more confusing this only appears to be a problem on some devices and not others. It is a problem on my iPad running iPadOS 15.2.1.
I have tried having the parent app, which did the file rename send a change notification but that doesn't seem to work either. If I call the following in my app:
[NSFileProviderManager.defaultManager signalEnumeratorForContainerItemIdentifier:identifier completionHandler:^(NSError * _Nullable error){
if (error != nil)
NSLog(@"signalEnumeratorForContainerItemIdentifier error:%@", error);
else {
NSLog(@"signalEnumeratorForContainerItemIdentifier OK");
}
}];
I see the following message in the console log from the fileproviderd:
[DEBUG] Received error NSError: Cocoa 3072 "" while sending didChangeItemID:completionHandler: on behalf of myApp[955]
Do I need to explicetly tell the files app when a file has been deleted or renamed?