fix: db migration to version 90 crashing the app and causing database wipe #9826
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.
Fixes #9825.
PR Description
This pull request addresses two related app crashes:
During the database migration to version 90, the app attempts to fetch the IMAP prefix from the email server. If there is no connection available at that time, the migration throws an exception. This exception leads to the
StoreSchemaDefinitionwiping out all the database data by setting the db version to 0.When trying to open the app with no available folders, a crash occurs because the code assumes there is at least one folder in the list when creating the drawer instance. Since the database has been wiped, no folders are present, making it impossible to open the app.
This pull request resolves both issues by:
IOExceptionthat occurs while attempting to fetch the IMAP prefix during the migration. If an exception is encountered, the data migration will be ignored.Steps to reproduce
git checkout dc3a253f6289cf45c737d49aa782a8a5bc69a714(Revision before db migration 90)git switch main && git pullExpected behaviour
Actual behaviour
The app crashes and wipes out the data.