Migrations from 1.0.x and 2.0 beta.

pull/1/head
Christine Corbett 10 years ago committed by Frederic Jacobs
parent b7d65ce921
commit a6976bac18

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

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

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

@ -16,6 +16,8 @@
#import "RecentCallManager.h" #import "RecentCallManager.h"
#import "SignalKeyingStorage.h" #import "SignalKeyingStorage.h"
#import "UICKeyChainStore.h" #import "UICKeyChainStore.h"
#import "TSStorageManager.h"
#import "TSDatabaseView.h"
@interface SignalKeyingStorage(VersionMigrations) @interface SignalKeyingStorage(VersionMigrations)
@ -46,6 +48,10 @@
} }
+ (void)migrateFrom2Dot0BetaTo2Dot0Dot10 {
[[TSStorageManager sharedManager] deleteThreadsAndMessages];
}
+ (void)migrateFrom1Dot0Dot2ToGreater { + (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 // 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

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

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

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

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

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

Loading…
Cancel
Save