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
This commit is contained in:
Michael Kirk 2016-09-26 21:57:34 -04:00 committed by GitHub
parent 14570cb6cf
commit 1433ee2655
4 changed files with 13 additions and 5 deletions

View File

@ -130,7 +130,7 @@ EXTERNAL SOURCES:
CHECKOUT OPTIONS:
SignalServiceKit:
:commit: 2dba7d141a4840eb96c1482e0dd2db11a854e6a3
:commit: 1098bc203e4ca2d7ae444b5a6e913b123455c5da
:git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket:
:commit: 8096fef47d582bff8ae3758c9ae7af1d55ea53d6

View File

@ -21,7 +21,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.5.1</string>
<string>2.5.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@ -38,7 +38,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2.5.1.0</string>
<string>2.5.2.2</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LOGS_EMAIL</key>

View File

@ -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];

View File

@ -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];
}