Skip to content

fix: restore Apple Files favorites after an extension restart - #4517

Open
zxxwyt wants to merge 2 commits into
nextcloud:masterfrom
zxxwyt:nc-ios/4410-favorites-working-set
Open

zxxwyt wants to merge 2 commits into
nextcloud:masterfrom
zxxwyt:nc-ios/4410-favorites-working-set

Conversation

@zxxwyt

@zxxwyt zxxwyt commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4410. This follows the requested changes in #4506.

Apple Files can ask for its working set before the user opens the Nextcloud location. On a cold start the provider had no account session, so enumeration could return before reporting any favorites.

  • The enumerator opens the shared Realm before looking up the working set’s account with the existing setupAccount. This matters on a cold start because the extension’s database singleton initially stores only the shared database URL. The existing authentication flow and item(for:) are unchanged.
  • Files’ folder ranks are stored per account, including reordering an existing favorite. Removing an account clears its ranks.
  • A working-set anchor is valid for one account and one extension process. After a restart the provider expires the old anchor, prompting Files to enumerate the saved favorites again.

Verification

Xcode 27.2 ran FileProviderFavoriteRanksTests and FileProviderWorkingSetChangesTests on an iPad Pro 13-inch (M5) simulator running iPadOS 26.0.1. All five tests passed with zero skips. They cover stored ranks after reopening, account removal and isolation, and invalidation of anchors from an earlier launch.

On iPhone 17 and iPad Pro simulators connected to Nextcloud Server 32.0.15, the favorites remained visible after terminating and relaunching both Apple Files and the File Provider extension. On iPhone, a nested favorite and a top-level favorite retained the order assigned in Files. After removing one favorite and restarting again, only the retained test folder appeared; WebDAV confirmed favorite values of 1 and 0. There is a separate navigation issue on cold start: the first tap on a favorite opened the Nextcloud root on both devices; a second tap opened the selected folder and displayed its test file.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (Codex:gpt-6.2-astra).

Codex helped implement the changes, write and run the tests, and draft this description.

Files can request its working set before opening the Nextcloud location. Open its account session at that point and expire anchors from previous processes so Files can reload favorites with their saved order. Remove those ranks when the account is deleted.

Assisted-by: Codex:gpt-6.2-astra
The extension database singleton only records the shared database URL at launch. On a cold working-set request, account lookup needs the existing schema check and Realm configuration before it can read the saved account.

Assisted-by: Codex:gpt-6.2-astra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nextcloud folders disappear from Apple Files Favorites after restarting the app

1 participant