Fixes an issue where users were no longer receiving messages after restoration. During restoration, the restoring device copies the transferred database files to a special "hotswap" directory since we don't want to overwrite our currently in-use database. Once finished, it re-opens the database pointing to our hotswap directory. It would then move the hotswap database to its primary location on the next app launch. The problem here is our extensions don't know how to read the hotswap directory. Even if we added that capability, it's going to be tricky to coordinate which database they read and when as the main app shuffles files around. This fix adjusts our restoration flow. Instead of having a special "primary" and "hotswap" directory that we need to fix up on the next launch, we instead record a UserDefaults entry that points to our current database directory. Once transfer has completed, the main app only needs to update the current database directory in UserDefaults. No post-launch swapping needs to occur. Extensions will listen for updates to this database location by registering KVO on NSUserDefaults. This change also adjusts the restoration flow to break it up into discrete stages. The motivation here is we need to make sure that a partial restoration doesn't put the extensions in an inconsistent state. |
||
|---|---|---|
| .. | ||
| AccountServiceClient.swift | ||
| CreatePreKeysOperation.swift | ||
| RefreshPreKeysOperation.swift | ||
| RotateSignedKeyOperation.swift | ||
| TSAccountManager.h | ||
| TSAccountManager.m | ||
| TSAccountManager.swift | ||
| TSPreKeyManager.h | ||
| TSPreKeyManager.m | ||
| TSPreKeyManager.swift | ||