Skip to content

feat: no longer implicitly set collection path when DB is used#21343

Open
david-allison wants to merge 2 commits into
ankidroid:mainfrom
david-allison:collection-helper-anki-common
Open

feat: no longer implicitly set collection path when DB is used#21343
david-allison wants to merge 2 commits into
ankidroid:mainfrom
david-allison:collection-helper-anki-common

Conversation

@david-allison

@david-allison david-allison commented Jul 6, 2026

Copy link
Copy Markdown
Member

Note

Assisted-by: Claude Fable 5

Purpose / Description

  • Removes the 'create collection' responsibility of getCurrentAnkiDroidDirectory via moving storage initialization into startup/SetupStorage.kt
  • ⚠️ Accessing the collection no longer initializes it

Fixes

Approach

  • Implement storageDecision() based on whether the collection path is set
  • Add error handling to DeckPicker if storageDecision isn't set
  • Initialization is moved to AnkiDroidApp
  • ⚠️ getCurrentAnkiDroidDirectory no longer sets the collection path; throwing StorageNotConfiguredException
  • ensureOpenInner also throws

I maintained SystemStorageException for the OS-level errors if context.getExternalFilesDir returns null

How Has This Been Tested?

Unit tested

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@david-allison david-allison added the Review High Priority Request for high priority review label Jul 6, 2026
@david-allison david-allison force-pushed the collection-helper-anki-common branch from cbe4d38 to f86073c Compare July 6, 2026 06:07
@lukstbit

lukstbit commented Jul 6, 2026

Copy link
Copy Markdown
Member

Reviewers: please let me know if you want me to split this out:

Yes, please do this.

@david-allison david-allison force-pushed the collection-helper-anki-common branch from f86073c to 33b2d1a Compare July 6, 2026 20:42
@david-allison david-allison changed the title feat: no longer implicitly set collection path when DB is used. Also move CollectionManager to :anki-common feat: no longer implicitly set collection path when DB is used Jul 6, 2026
Breaking change, this was previously done on first collection access.

Now this is set in AnkiDroidApp, and reading throws
StorageNotConfiguredException beforehand.

This contains a workaround for the OS-level bug: `SystemStorageException`
if the exception is caught, it is explicitly rethrown.

This is preparation for a full 'storage decision' screen during onboarding

* Part of 19552
* Part of 13574
* Part of 20737

Assisted-by: Claude Fable 5
The decision now mirrors whether `getCurrentAnkiDroidDirectory`
is usable or throws.

The path is set during startup (`ensureCollectionPathSet`),
so `Undecided` is only observable if startup storage initialization
failed.

This is now classified as an `InitializationError` and displayed in
the app startup flow (with a TODO for 19552 to improve this).

* Part of 19552
* Part of 13574

Assisted-by: Claude Fable 5
@david-allison david-allison force-pushed the collection-helper-anki-common branch from 33b2d1a to 9ac0a08 Compare July 6, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Review High Priority Request for high priority review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants