In my file provider the URL path I get when the a file is modified and the files app calls itemChangedAtURL starts with "/var/..." but in all other cases the URLs start with "/private/var/...".
As a result when I call [self persistentIdentifierForItemAtURL: url] I get nil back because it doesn't recognize the path.
I know that /var is actually a link to /private/var but am I expected to resolve this internally?
Here is some of my code:
- (nullable NSFileProviderItemIdentifier)persistentIdentifierForItemAtURL:(NSURL *)url {
//NSLog(@"FileProviderExtension persistentIdentifierForItemAtURL");
// resolve the given URL to a persistent identifier
if (!url || ![url isFileURL])
return nil;
NSString *prefixPath = [_myRoot stringByAppendingPathComponent:@"/"];
NSString* urlPath = [url path];
NSLog(@"FileProviderExtension persistentIdentifierForItemAtURL prefixPath:%@ urlPath:%@", prefixPath, urlPath);
if (!prefixPath || !urlPath || (urlPath.length <= prefixPath.length)) {
NSLog(@"FileProviderExtension bad-URL persistentIdentifierForItemAtURL prefixPath:%@ urlPath:%@", prefixPath, urlPath);
return nil;
}
NSRange prefixRange = [urlPath rangeOfString:prefixPath];
if ((prefixRange.location == NSNotFound) || (prefixRange.length == 0)){
NSLog(@"FileProviderExtension bad-URL persistentIdentifierForItemAtURL prefixPath:%@ urlPath:%@ prefixRange :%lu", prefixPath, urlPath, prefixRange.length);
return nil;
}
return [urlPath substringWithRange:NSMakeRange(prefixRange.length, urlPath.length - prefixRange.length)];;
}
- (void)itemChangedAtURL:(NSURL *)url {
NSLog(@"FileProviderExtension myPlaceholder itemChangedAtURL: %@", url);
NSFileProviderItemIdentifier itemIdentifier = [self persistentIdentifierForItemAtURL: url];
if (itemIdentifier)
[self notifyPathChanged:[self parentIdentifierForItemIdentifier: itemIdentifier]];
}