Assert that GRDB schema/data migrations are complete before we warm caches.
This commit is contained in:
parent
004717ff35
commit
b058317777
@ -27,6 +27,8 @@ public class PaymentsCurrenciesImpl: NSObject, PaymentsCurrenciesSwift {
|
||||
}
|
||||
|
||||
public func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
Self.databaseStorage.read { transaction in
|
||||
self.currentCurrencyCode = Self.loadCurrentCurrencyCode(transaction: transaction)
|
||||
}
|
||||
|
||||
@ -169,6 +169,8 @@ public class PaymentsImpl: NSObject, PaymentsSwift {
|
||||
public static let arePaymentsEnabledDidChange = Notification.Name("arePaymentsEnabledDidChange")
|
||||
|
||||
public func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
Self.databaseStorage.read { transaction in
|
||||
self.paymentStateCache.set(Self.loadPaymentsState(transaction: transaction))
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ public enum Wallpaper: String, CaseIterable {
|
||||
public static var defaultWallpapers: [Wallpaper] { allCases.filter { $0 != .photo } }
|
||||
|
||||
public static func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
owsAssertDebug(!Thread.isMainThread)
|
||||
|
||||
guard CurrentAppContext().hasUI else { return }
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SignalCoreKit
|
||||
|
||||
public struct ChatColor: Equatable, Codable {
|
||||
public let id: String
|
||||
@ -59,6 +60,8 @@ public class ChatColors: NSObject, Dependencies {
|
||||
// The cache should contain all current values at all times.
|
||||
@objc
|
||||
private func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
guard CurrentAppContext().hasUI else { return }
|
||||
|
||||
var valueCache = [String: ChatColor]()
|
||||
|
||||
@ -197,6 +197,8 @@ const NSString *kNSNotificationKey_UserProfileWriter = @"kNSNotificationKey_User
|
||||
|
||||
- (void)warmCaches
|
||||
{
|
||||
OWSAssertDebug(GRDBSchemaMigrator.areMigrationsComplete);
|
||||
|
||||
// Clear out so we re-initialize if we ever re-run the "on launch" logic,
|
||||
// such as after a completed database transfer.
|
||||
@synchronized(self) {
|
||||
@ -217,6 +219,8 @@ const NSString *kNSNotificationKey_UserProfileWriter = @"kNSNotificationKey_User
|
||||
|
||||
- (OWSUserProfile *)localUserProfile
|
||||
{
|
||||
OWSAssertDebug(GRDBSchemaMigrator.areMigrationsComplete);
|
||||
|
||||
@synchronized(self)
|
||||
{
|
||||
if (_localUserProfile) {
|
||||
@ -262,6 +266,8 @@ const NSString *kNSNotificationKey_UserProfileWriter = @"kNSNotificationKey_User
|
||||
|
||||
- (nullable OWSUserProfile *)getLocalUserProfileWithTransaction:(SDSAnyReadTransaction *)transaction
|
||||
{
|
||||
OWSAssertDebug(GRDBSchemaMigrator.areMigrationsComplete);
|
||||
|
||||
@synchronized(self) {
|
||||
if (_localUserProfile) {
|
||||
OWSAssertDebug(_localUserProfile.profileKey);
|
||||
@ -286,6 +292,8 @@ const NSString *kNSNotificationKey_UserProfileWriter = @"kNSNotificationKey_User
|
||||
|
||||
- (void)localProfileWasUpdated:(OWSUserProfile *)localUserProfile
|
||||
{
|
||||
OWSAssertDebug(GRDBSchemaMigrator.areMigrationsComplete);
|
||||
|
||||
@synchronized(self) {
|
||||
_localUserProfile = [localUserProfile shallowCopy];
|
||||
}
|
||||
@ -699,6 +707,8 @@ const NSString *kNSNotificationKey_UserProfileWriter = @"kNSNotificationKey_User
|
||||
userProfileWriter:(UserProfileWriter)userProfileWriter
|
||||
transaction:(SDSAnyWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssertDebug(GRDBSchemaMigrator.areMigrationsComplete);
|
||||
|
||||
OWSUserProfile *localUserProfile;
|
||||
|
||||
@synchronized(self)
|
||||
|
||||
@ -248,6 +248,8 @@ NSString *NSStringForOWSRegistrationState(OWSRegistrationState value)
|
||||
|
||||
- (void)warmCaches
|
||||
{
|
||||
OWSAssertDebug(GRDBSchemaMigrator.areMigrationsComplete);
|
||||
|
||||
TSAccountState *accountState = [self loadAccountStateWithSneakyTransaction];
|
||||
|
||||
[accountState log];
|
||||
|
||||
@ -423,6 +423,8 @@ public class SignalServiceAddressCache: NSObject {
|
||||
|
||||
@objc
|
||||
func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
let localNumber = TSAccountManager.shared.localNumber
|
||||
let localUuid = TSAccountManager.shared.localUuid
|
||||
|
||||
|
||||
@ -229,6 +229,8 @@ public class BlockingManager: NSObject {
|
||||
|
||||
@objc
|
||||
public func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
loadStateOnLaunch()
|
||||
}
|
||||
|
||||
|
||||
@ -201,6 +201,8 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
|
||||
|
||||
@objc
|
||||
public func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
let parseUnidentifiedAccessMode = { (anyValue: Any) -> UnidentifiedAccessMode? in
|
||||
guard let nsNumber = anyValue as? NSNumber else {
|
||||
owsFailDebug("Invalid value.")
|
||||
|
||||
@ -8,6 +8,10 @@ import GRDB
|
||||
@objc
|
||||
public class GRDBSchemaMigrator: NSObject {
|
||||
|
||||
private static let _areMigrationsComplete = AtomicBool(false)
|
||||
@objc
|
||||
public static var areMigrationsComplete: Bool { _areMigrationsComplete.get() }
|
||||
|
||||
// Returns true IFF incremental migrations were performed.
|
||||
@objc
|
||||
public func runSchemaMigrations() -> Bool {
|
||||
@ -26,6 +30,8 @@ public class GRDBSchemaMigrator: NSObject {
|
||||
|
||||
SSKPreferences.markGRDBSchemaAsLatest()
|
||||
|
||||
Self._areMigrationsComplete.set(true)
|
||||
|
||||
return didPerformIncrementalMigrations
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +59,8 @@ public class AppExpiry: NSObject {
|
||||
}
|
||||
|
||||
private func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
if let persistedExpirationState: ExpirationState = databaseStorage.read(block: { transaction in
|
||||
guard let persistedExpirationState: ExpirationState = try? self.keyValueStore.getCodableValue(
|
||||
forKey: Self.expirationStateKey,
|
||||
|
||||
@ -650,6 +650,8 @@ public class KeyBackupService: NSObject {
|
||||
|
||||
@objc
|
||||
public static func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
let state = getOrLoadStateWithSneakyTransaction()
|
||||
migrateEnclavesIfNecessary(state: state)
|
||||
}
|
||||
|
||||
@ -22,6 +22,8 @@ public class PinnedThreadManager: NSObject {
|
||||
|
||||
@objc
|
||||
public class func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
let pinnedThreadIds = SDSDatabaseStorage.shared.read { transaction in
|
||||
return keyValueStore.getObject(
|
||||
forKey: pinnedThreadIdsKey,
|
||||
|
||||
@ -509,6 +509,8 @@ public class ServiceRemoteConfigManager: NSObject, RemoteConfigManager {
|
||||
}
|
||||
|
||||
public func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
cacheCurrent()
|
||||
|
||||
AppReadiness.runNowOrWhenAppWillBecomeReady {
|
||||
|
||||
@ -66,6 +66,8 @@ public class TypingIndicatorsImpl: NSObject, TypingIndicators {
|
||||
|
||||
@objc
|
||||
public func warmCaches() {
|
||||
owsAssertDebug(GRDBSchemaMigrator.areMigrationsComplete)
|
||||
|
||||
let enabled = databaseStorage.read { transaction in
|
||||
self.keyValueStore.getBool(
|
||||
self.kDatabaseKey_TypingIndicatorsEnabled,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user