Migrations from 1.0.x and 2.0 beta.

This commit is contained in:
Christine Corbett 2015-01-30 16:50:48 -10:00 committed by Frederic Jacobs
parent b7d65ce921
commit a6976bac18
9 changed files with 32 additions and 9 deletions

View File

@ -38,7 +38,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2.0.1</string>
<string>2.0.10</string>
<key>LOGS_EMAIL</key>
<string>support@whispersystems.org</string>
<key>LOGS_URL</key>

View File

@ -21,7 +21,7 @@
#import "UIColor+OWS.h"
#import "CodeVerificationViewController.h"
#import "MIMETypeUtil.h"
#import "TSDatabaseView.h"
#import <PastelogKit/Pastelog.h>
#define kSignalVersionKey @"SignalUpdateVersionKey"
@ -49,22 +49,33 @@ static NSString* const kCallSegue = @"2.0_6.0_Call_Segue";
- (void)performUpdateCheck{
NSString *previousVersion = Environment.preferences.lastRanVersion;
NSString *currentVersion = [Environment.preferences setAndGetCurrentVersion];
// TODO: remove
if (!previousVersion) {
DDLogError(@"No previous version found. Possibly first launch since install.");
[Environment resetAppData]; // We clean previous keychain entries in case their are some entries remaining.
}
else if ([Environment.preferences getIsMigratingToVersion2Dot0] || [currentVersion compare:previousVersion options:NSNumericSearch] == NSOrderedDescending){
if([self isVersion:previousVersion atLeast:@"1.0.2"]) {
[VersionMigrations migrateFrom1Dot0Dot2ToVersion2Dot0]; // this is only necessary for older apps
else if(([self isVersion:previousVersion atLeast:@"1.0.2" andLessThan:@"2.0"]) || [Environment.preferences getIsMigratingToVersion2Dot0] ) {
[VersionMigrations migrateFrom1Dot0Dot2ToVersion2Dot0];
}
else if([self isVersion:previousVersion atLeast:@"2.0" andLessThan:@"2.0.10"]){
[VersionMigrations migrateFrom2Dot0BetaTo2Dot0Dot10];
}
}
-(BOOL) isVersion:(NSString *)thisVersionString atLeast:(NSString *)openLowerBoundVersionString andLessThan:(NSString *)closedUpperBoundVersionString {
return [self isVersion:thisVersionString atLeast:openLowerBoundVersionString] && [self isVersion:thisVersionString lessThan:closedUpperBoundVersionString];
}
- (BOOL) isVersion:(NSString *)thisVersionString atLeast:(NSString *)thatVersionString {
return [thisVersionString compare:thatVersionString options:NSNumericSearch] != NSOrderedAscending;
}
- (BOOL) isVersion:(NSString *)thisVersionString lessThan:(NSString *)thatVersionString {
return [thisVersionString compare:thatVersionString options:NSNumericSearch] == NSOrderedAscending;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
BOOL loggingIsEnabled;
[self setupAppearance];
@ -90,13 +101,15 @@ static NSString* const kCallSegue = @"2.0_6.0_Call_Segue";
self.notificationTracker = [NotificationTracker notificationTracker];
[self performUpdateCheck];
CategorizingLogger* logger = [CategorizingLogger categorizingLogger];
[logger addLoggingCallback:^(NSString *category, id details, NSUInteger index) {}];
[Environment setCurrent:[Release releaseEnvironmentWithLogging:logger]];
[Environment.getCurrent.phoneDirectoryManager startUntilCancelled:nil];
[Environment.getCurrent.contactsManager doAfterEnvironmentInitSetup];
[self performUpdateCheck]; // this call must be made after environment has been initialized because in general upgrade may depend on environment
//Accept push notification when app is not open
NSDictionary *remoteNotif = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if (remoteNotif) {

View File

@ -14,5 +14,6 @@
+ (void)migrateFrom1Dot0Dot2ToGreater;
+ (void)migrateFrom1Dot0Dot2ToVersion2Dot0;
+ (void)migrateFrom2Dot0BetaTo2Dot0Dot10;
@end

View File

@ -16,6 +16,8 @@
#import "RecentCallManager.h"
#import "SignalKeyingStorage.h"
#import "UICKeyChainStore.h"
#import "TSStorageManager.h"
#import "TSDatabaseView.h"
@interface SignalKeyingStorage(VersionMigrations)
@ -46,6 +48,10 @@
}
+ (void)migrateFrom2Dot0BetaTo2Dot0Dot10 {
[[TSStorageManager sharedManager] deleteThreadsAndMessages];
}
+ (void)migrateFrom1Dot0Dot2ToGreater {
// Preferences were stored in both a preference file and a plist in the documents folder, as a temporary measure, we are going to move all the preferences to the NSUserDefaults preference store, those will be migrated to a SQLCipher-backed database

View File

@ -82,6 +82,7 @@
inCollection:TSStorageManagerSessionStoreCollection];
}
- (NSNumber*)keyForInt:(int)number {
return [NSNumber numberWithInt:number];
}

View File

@ -22,4 +22,5 @@ extern NSString *TSUnreadDatabaseViewExtensionName;
+ (BOOL)registerBuddyConversationDatabaseView;
+ (BOOL)registerUnreadDatabaseView;
@end

View File

@ -28,7 +28,6 @@ NSString *TSUnreadDatabaseViewExtensionName = @"TSUnreadDatabaseViewExtensionNa
@implementation TSDatabaseView
+ (BOOL)registerUnreadDatabaseView {
YapDatabaseView *unreadView = [[TSStorageManager sharedManager].database registeredExtension:TSUnreadDatabaseViewExtensionName];
if (unreadView) {
return YES;

View File

@ -80,6 +80,8 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass";
[self.database registerExtension:[[YapDatabaseRelationship alloc] init] withName:@"TSRelationships"];
}
- (void)protectSignalFiles{
[self protectFolderAtPath:[TSAttachmentStream attachmentsFolder]];
[self protectFolderAtPath:[self dbPath]];

View File

@ -21,7 +21,7 @@
#import "TSContactThread.h"
#import "TSMessagesManager+sendMessages.h"
#import "UIImage+normalizeImage.h"
#import "PreferencesUtil.h"
#import "NSDate+millisecondTimeStamp.h"
#import <YapDatabase/YapDatabaseViewChange.h>
@ -88,7 +88,7 @@ static NSString* const kShowSignupFlowSegue = @"showSignupFlow";
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
if (![TSAccountManager isRegistered]){
if (![TSAccountManager isRegistered] && ![Environment.preferences getIsMigratingToVersion2Dot0]){
[self performSegueWithIdentifier:kShowSignupFlowSegue sender:self];
}
}