close
Skip to content

fix(file-provider): report a different error if database is not ready#8885

Merged
nilsding merged 1 commit into
masterfrom
bugfix/noid/macos-init-disappearing-cloudstorage-directory
Oct 15, 2025
Merged

fix(file-provider): report a different error if database is not ready#8885
nilsding merged 1 commit into
masterfrom
bugfix/noid/macos-init-disappearing-cloudstorage-directory

Conversation

@nilsding
Copy link
Copy Markdown
Member

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 .cannotSynchronize is 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:

% grep "Not fetching item because database is unavailable." fp-bob-failedinit.jsonl fp-bob-workinginit.jsonl 
fp-bob-failedinit.jsonl:{"category":"FileProviderExtension","date":"2025.10.15 16:09:37.902","details":{"item":"NSFileProviderRootContainerItemIdentifier"},"level":"error","message":"Not fetching item because database is unavailable."}

As per [the docs for `NSFileProviderReplicatedExtension
item(for:request:completionHandler:)`][1], 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 `.cannotSynchronize` is
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.

[1]: https://developer.apple.com/documentation/fileprovider/nsfileproviderreplicatedextension/item(for:request:completionhandler:)#Discussion

Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
@nilsding nilsding added this to the 4.1.0 milestone Oct 15, 2025
@nilsding nilsding self-assigned this Oct 15, 2025
@nilsding nilsding requested a review from Aiiaiiio as a code owner October 15, 2025 15:04
@nilsding nilsding added the os: 🍎 macOS Apple macOS, formerly also known as OS X label Oct 15, 2025
@nilsding nilsding added 3. to review feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. labels Oct 15, 2025
@nilsding
Copy link
Copy Markdown
Member Author

/backport to stable-4.0

@Rello Rello self-requested a review October 15, 2025 15:15
@nilsding nilsding enabled auto-merge October 15, 2025 15:26
@nilsding nilsding disabled auto-merge October 15, 2025 15:27
@nilsding nilsding enabled auto-merge October 15, 2025 15:32
@github-actions
Copy link
Copy Markdown
Contributor

Artifact containing the AppImage: nextcloud-appimage-pr-8885.zip

Digest: sha256:855d7b441518b081df5f84891daa28f198eaa2f53d7f050859449373a5cadaa4

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

@nilsding nilsding disabled auto-merge October 15, 2025 15:45
@nilsding nilsding merged commit 979b6cf into master Oct 15, 2025
19 of 20 checks passed
@nilsding nilsding deleted the bugfix/noid/macos-init-disappearing-cloudstorage-directory branch October 15, 2025 15:45
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. os: 🍎 macOS Apple macOS, formerly also known as OS X

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants