Why is the url passed in in NSFileProviderExtension:itemChangedAtURL different from NSFileProviderExtension:startProvidingItemAtURL?

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]];
}

To answer my own question it looks like the solution is to always use NSString stringByResolvingSymlinksInPath to resolve any symbolic links before trying to compare paths.

My '_myRoot' contained a symbolic link because the path to the shared group folder returned by [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier: group_id] contains symbolic links.

Why is the url passed in in NSFileProviderExtension:itemChangedAtURL different from NSFileProviderExtension:startProvidingItemAtURL?
 
 
Q