diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index c06b16882..0f8d406d6 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -225,15 +225,17 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; return; } - DDLogInfo(@"%@ Database file size: %@", - self.logTag, - [OWSFileSystem fileSizeOfPath:TSStorageManager.legacyDatabaseFilePath]); - DDLogInfo(@"%@ \t SHM file size: %@", - self.logTag, - [OWSFileSystem fileSizeOfPath:TSStorageManager.legacyDatabaseFilePath_SHM]); - DDLogInfo(@"%@ \t WAL file size: %@", - self.logTag, - [OWSFileSystem fileSizeOfPath:TSStorageManager.legacyDatabaseFilePath_WAL]); + if ([NSFileManager.defaultManager fileExistsAtPath:TSStorageManager.legacyDatabaseFilePath]) { + DDLogInfo(@"%@ Database file size: %@", + self.logTag, + [OWSFileSystem fileSizeOfPath:TSStorageManager.legacyDatabaseFilePath]); + DDLogInfo(@"%@ \t SHM file size: %@", + self.logTag, + [OWSFileSystem fileSizeOfPath:TSStorageManager.legacyDatabaseFilePath_SHM]); + DDLogInfo(@"%@ \t WAL file size: %@", + self.logTag, + [OWSFileSystem fileSizeOfPath:TSStorageManager.legacyDatabaseFilePath_WAL]); + } NSError *_Nullable error = [self convertDatabaseIfNecessary]; // TODO: Handle this error. diff --git a/SignalMessaging/contacts/SystemContactsFetcher.swift b/SignalMessaging/contacts/SystemContactsFetcher.swift index 8f12e0c01..f58bee2f9 100644 --- a/SignalMessaging/contacts/SystemContactsFetcher.swift +++ b/SignalMessaging/contacts/SystemContactsFetcher.swift @@ -62,7 +62,7 @@ class ContactsFrameworkContactStoreAdaptee: ContactStoreAdaptee { @objc func didBecomeActive() { - AppReadiness.runNowOr { + AppReadiness.runNowOrWhenAppIsReady { let currentSortOrder = CNContactsUserDefaults.shared().sortOrder guard currentSortOrder != self.lastSortOrder else { diff --git a/SignalMessaging/environment/migrations/OWS104CreateRecipientIdentities.m b/SignalMessaging/environment/migrations/OWS104CreateRecipientIdentities.m index 486f0b858..02f0f8df9 100644 --- a/SignalMessaging/environment/migrations/OWS104CreateRecipientIdentities.m +++ b/SignalMessaging/environment/migrations/OWS104CreateRecipientIdentities.m @@ -54,8 +54,6 @@ static NSString *const OWS104CreateRecipientIdentitiesMigrationId = @"104"; verificationState:OWSVerificationStateDefault] saveWithTransaction:transaction]; }]; - - [self saveWithTransaction:transaction]; } @end diff --git a/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m b/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m index 117eba4c1..88863cae4 100644 --- a/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m +++ b/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m @@ -80,6 +80,7 @@ NS_ASSUME_NONNULL_BEGIN NSUInteger totalMigrationCount = migrationsToRun.count; __block NSUInteger completedMigrationCount = 0; + // Call the completion exactly once, when the last migration completes. void (^checkMigrationCompletion)(void) = ^{ @synchronized(self) { diff --git a/SignalServiceKit/src/Storage/OWSStorage.m b/SignalServiceKit/src/Storage/OWSStorage.m index fb5d50a56..f99e40c06 100644 --- a/SignalServiceKit/src/Storage/OWSStorage.m +++ b/SignalServiceKit/src/Storage/OWSStorage.m @@ -741,16 +741,7 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void); - (unsigned long long)databaseFileSize { - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSError *_Nullable error; - unsigned long long fileSize = - [[fileManager attributesOfItemAtPath:self.databaseFilePath error:&error][NSFileSize] unsignedLongLongValue]; - if (error) { - DDLogError(@"%@ Couldn't fetch database file size: %@", self.logTag, error); - } else { - DDLogInfo(@"%@ Database file size: %llu", self.logTag, fileSize); - } - return fileSize; + return [OWSFileSystem fileSizeOfPath:self.databaseFilePath].unsignedLongLongValue; } + (void)storeKeyChainValue:(NSData *)data keychainKey:(NSString *)keychainKey diff --git a/SignalServiceKit/src/Storage/TSDatabaseView.m b/SignalServiceKit/src/Storage/TSDatabaseView.m index ad601577f..77d4a651f 100644 --- a/SignalServiceKit/src/Storage/TSDatabaseView.m +++ b/SignalServiceKit/src/Storage/TSDatabaseView.m @@ -53,7 +53,6 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic + (void)registerMessageDatabaseViewWithName:(NSString *)viewName viewGrouping:(YapDatabaseViewGrouping *)viewGrouping version:(NSString *)version - async:(BOOL)async storage:(OWSStorage *)storage { OWSAssertIsOnMainThread(); @@ -78,12 +77,7 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic sorting:viewSorting versionTag:version options:options]; - - if (async) { - [storage asyncRegisterExtension:view withName:viewName]; - } else { - [storage registerExtension:view withName:viewName]; - } + [storage asyncRegisterExtension:view withName:viewName]; } + (void)asyncRegisterUnreadDatabaseView:(OWSStorage *)storage @@ -102,7 +96,6 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic [self registerMessageDatabaseViewWithName:TSUnreadDatabaseViewExtensionName viewGrouping:viewGrouping version:@"1" - async:YES storage:storage]; } @@ -122,7 +115,6 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic [self registerMessageDatabaseViewWithName:TSUnseenDatabaseViewExtensionName viewGrouping:viewGrouping version:@"1" - async:YES storage:storage]; } @@ -150,7 +142,6 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic [self registerMessageDatabaseViewWithName:TSThreadSpecialMessagesDatabaseViewExtensionName viewGrouping:viewGrouping version:@"1" - async:YES storage:storage]; } @@ -167,7 +158,6 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic [self registerMessageDatabaseViewWithName:TSMessageDatabaseViewExtensionName viewGrouping:viewGrouping version:@"1" - async:YES storage:storage]; } @@ -184,7 +174,6 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic [self registerMessageDatabaseViewWithName:TSThreadOutgoingMessageDatabaseViewExtensionName viewGrouping:viewGrouping version:@"2" - async:YES storage:storage]; } diff --git a/SignalServiceKit/src/Util/AppReadiness.h b/SignalServiceKit/src/Util/AppReadiness.h index 8ac27de86..837b13752 100755 --- a/SignalServiceKit/src/Util/AppReadiness.h +++ b/SignalServiceKit/src/Util/AppReadiness.h @@ -23,7 +23,7 @@ typedef void (^AppReadyBlock)(void); // // This method should only be called on the main thread. // The block will always be called on the main thread. -+ (void)runNowOrWhenAppIsReady:(AppReadyBlock)block; ++ (void)runNowOrWhenAppIsReady:(AppReadyBlock)block NS_SWIFT_NAME(runNowOrWhenAppIsReady(_:)); @end diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index 4ec2fde3d..98ee93a15 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -363,9 +363,9 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE Logger.debug("\(self.logTag) \(#function)") if isReadyForAppExtensions { - AppReadiness.runNowOr(whenAppIsReady: { + AppReadiness.runNowOrWhenAppIsReady { self.activate() - }) + } } }