Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MXBackgroundSyncService: Clear the bg sync crypto db if needed #997

Merged
merged 11 commits into from
Jan 22, 2021

Conversation

manuroe
Copy link
Contributor

@manuroe manuroe commented Jan 20, 2021

so that we will be able to even clear corrupted db. This should fix element-hq/element-ios#3956.

It does not prevent the corruption (even Realm does not know how it can happen) but the app and the NSE will auto fix themselves. The user will just need to open the app.
Opening the app will clear the background sync cache. On the next push, the bg sync service will detect that the bg sync cache is empty, it will then clear the realm db. Any corrupted db issue is solved.
Some notifications will not be able to decrypt but messages will be readable within the app.

This required some changes in MXRealmCryptoStore to delete the db without opening it.

manuroe and others added 3 commits January 20, 2021 15:32
…once per push

We dit it twice in a row for each new push. 
As launchBackgroundSync can be called several times to fetch keys. This is also dangerous to reset caches in the middle of the process of a push.

[RLM deleteFilesForConfiguration:] does not like to be called twice in a row
…impl in case of error

The old implementation requires a valid db but if the db is already opened. We can expect it to be valid.
@manuroe manuroe merged commit a06de88 into develop Jan 22, 2021
@manuroe manuroe deleted the 3956_reset_nse_crypto_db branch January 22, 2021 13:28
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.

Corrupted realm db in Notification Service Extension
2 participants