fix(file-provider): report a different error if database is not ready #8885
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



As per the docs for
NSFileProviderReplicatedExtension item(for:request:completionHandler:), the system will automatically retry calling the method if the error is not one of.notAuthenticated,.serverUnreachable, or.noSuchItem.From my observations it seems that if the error
.cannotSynchronizeis returned for the root container (i.e.NSFileProviderRootContainerItemIdentifier), the system/file provider framework just ends up deleting the newly created sync directory inside~/Library/CloudStorage. This broke the entry in the Finder sidebar.After changing the error to
.notAuthenticated(which is semantically wrong, but alas), I now could disable/enable the File Provider as often as I wanted without the Finder sidebar entry to ever break due to the directory having been removed previously ... Strange, this.I discovered this by comparing the logs when setting up the File Provider for the same account. The logs of such a failed invocation contained the following message, whereas successful ones did not: