From 1433ee26551034064525c3a6c215facd844253e5 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 26 Sep 2016 21:57:34 -0400 Subject: [PATCH] Fix crash on boot =/ (#1349) I botched a migration 6 months ago, which left some lingering TSRecipients serialized in our data store, laying in wait to explode the next time we enumerate every object in the database (e.g. when we add an index). The bloom filter migration failed to remove TSRecipients in the somewhat rare event that the local user had no downloaded bloom filters. This could happen e.g. if they were low on disk space at the time of running the migration, I believe the app would remove the bloom filter cache. // FREEBIE --- Podfile.lock | 2 +- Signal/Signal-Info.plist | 4 ++-- Signal/src/AppDelegate.m | 4 ++-- Signal/src/environment/VersionMigrations.m | 8 ++++++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 06cbdd7fc..b427296cb 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -130,7 +130,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: SignalServiceKit: - :commit: 2dba7d141a4840eb96c1482e0dd2db11a854e6a3 + :commit: 1098bc203e4ca2d7ae444b5a6e913b123455c5da :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 8096fef47d582bff8ae3758c9ae7af1d55ea53d6 diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index de417bee2..25023fcdc 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -21,7 +21,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.5.1 + 2.5.2 CFBundleSignature ???? CFBundleURLTypes @@ -38,7 +38,7 @@ CFBundleVersion - 2.5.1.0 + 2.5.2.2 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 514af3c05..05d0f23d6 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -60,8 +60,6 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; } [Environment.getCurrent initCallListener]; - [self setupTSKitEnv]; - BOOL loggingIsEnabled; #ifdef DEBUG @@ -78,6 +76,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; [DebugLogger.sharedLogger enableFileLogging]; } + [self setupTSKitEnv]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:kStoryboardName bundle:[NSBundle mainBundle]]; UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:kInitialViewControllerIdentifier]; diff --git a/Signal/src/environment/VersionMigrations.m b/Signal/src/environment/VersionMigrations.m index 722ec6f91..7c5c3ba11 100644 --- a/Signal/src/environment/VersionMigrations.m +++ b/Signal/src/environment/VersionMigrations.m @@ -75,6 +75,14 @@ }); } + if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.5.2"] && [TSAccountManager isRegistered]) { + [[TSStorageManager sharedManager].dbConnection + readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { + NSUInteger legacyRecipientCount = [transaction numberOfKeysInCollection:@"TSRecipient"]; + DDLogWarn(@"Removing %lu objects from TSRecipient collection", (unsigned long)legacyRecipientCount); + [transaction removeAllObjectsInCollection:@"TSRecipient"]; + }]; + } [Environment.preferences setAndGetCurrentVersion]; }