Respond to CR.

pull/1/head
Matthew Chen 8 years ago
parent 779e89fe74
commit 8d4e9b4565

@ -188,6 +188,6 @@ SPEC CHECKSUMS:
YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54 YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
PODFILE CHECKSUM: 8e42a06de2d254e448580cfd6212545739de62d6 PODFILE CHECKSUM: 558b99b22f87c7fb6e4a9c3084b14a384203d431
COCOAPODS: 1.3.1 COCOAPODS: 1.3.1

@ -24,6 +24,7 @@
#import "VersionMigrations.h" #import "VersionMigrations.h"
#import "ViewControllerUtils.h" #import "ViewControllerUtils.h"
#import <AxolotlKit/SessionCipher.h> #import <AxolotlKit/SessionCipher.h>
#import <SignalMessaging/SignalMessaging.h>
#import <SignalServiceKit/NSUserDefaults+OWS.h> #import <SignalServiceKit/NSUserDefaults+OWS.h>
#import <SignalServiceKit/OWSBatchMessageProcessor.h> #import <SignalServiceKit/OWSBatchMessageProcessor.h>
#import <SignalServiceKit/OWSDisappearingMessagesJob.h> #import <SignalServiceKit/OWSDisappearingMessagesJob.h>
@ -39,7 +40,6 @@
#import <SignalServiceKit/TSSocketManager.h> #import <SignalServiceKit/TSSocketManager.h>
#import <SignalServiceKit/TSStorageManager+Calling.h> #import <SignalServiceKit/TSStorageManager+Calling.h>
#import <SignalServiceKit/TextSecureKitEnv.h> #import <SignalServiceKit/TextSecureKitEnv.h>
#import <SignalMessaging/SignalMessaging.h>
@import WebRTC; @import WebRTC;
@import Intents; @import Intents;
@ -104,13 +104,14 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
DDLogWarn(@"%@ application: didFinishLaunchingWithOptions.", self.logTag); DDLogWarn(@"%@ application: didFinishLaunchingWithOptions.", self.logTag);
// We need to this _after_ we set up logging but _before_ we do // We need to do this _after_ we set up logging but _before_ we do
// anything else. // anything else.
[self ensureIsReadyForAppExtensions]; [self ensureIsReadyForAppExtensions];
#if RELEASE #if RELEASE
// ensureIsReadyForAppExtensions may have changed the state of the logging // ensureIsReadyForAppExtensions may have changed the state of the logging
// preference, so honor that change if necessary. // preference (due to [NSUserDefaults migrateToSharedUserDefaults]), so honor
// that change if necessary.
if (loggingIsEnabled && !OWSPreferences.loggingIsEnabled) { if (loggingIsEnabled && !OWSPreferences.loggingIsEnabled) {
[DebugLogger.sharedLogger disableFileLogging]; [DebugLogger.sharedLogger disableFileLogging];
} }

@ -1384,20 +1384,20 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
return image; return image;
} }
+ (NSString *)oldProfileAvatarsDirPath + (NSString *)legacyProfileAvatarsDirPath
{ {
return [[OWSFileSystem appDocumentDirectoryPath] stringByAppendingPathComponent:@"ProfileAvatars"]; return [[OWSFileSystem appDocumentDirectoryPath] stringByAppendingPathComponent:@"ProfileAvatars"];
} }
+ (NSString *)newProfileAvatarsDirPath + (NSString *)sharedDataProfileAvatarsDirPath
{ {
return [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"ProfileAvatars"]; return [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"ProfileAvatars"];
} }
+ (void)migrateToSharedData + (void)migrateToSharedData
{ {
[OWSFileSystem moveAppFilePath:self.oldProfileAvatarsDirPath [OWSFileSystem moveAppFilePath:self.legacyProfileAvatarsDirPath
sharedDataFilePath:self.newProfileAvatarsDirPath sharedDataFilePath:self.sharedDataProfileAvatarsDirPath
exceptionName:@"ProfileManagerCouldNotMigrateProfileDirectory"]; exceptionName:@"ProfileManagerCouldNotMigrateProfileDirectory"];
} }
@ -1406,7 +1406,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
static NSString *profileAvatarsDirPath = nil; static NSString *profileAvatarsDirPath = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
profileAvatarsDirPath = OWSProfileManager.newProfileAvatarsDirPath; profileAvatarsDirPath = OWSProfileManager.sharedDataProfileAvatarsDirPath;
BOOL isDirectory; BOOL isDirectory;
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:profileAvatarsDirPath isDirectory:&isDirectory]; BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:profileAvatarsDirPath isDirectory:&isDirectory];

@ -180,20 +180,20 @@ NS_ASSUME_NONNULL_BEGIN
return [dataSource writeToPath:filePath]; return [dataSource writeToPath:filePath];
} }
+ (NSString *)oldAttachmentsDirPath + (NSString *)legacyAttachmentsDirPath
{ {
return [[OWSFileSystem appDocumentDirectoryPath] stringByAppendingPathComponent:@"Attachments"]; return [[OWSFileSystem appDocumentDirectoryPath] stringByAppendingPathComponent:@"Attachments"];
} }
+ (NSString *)newAttachmentsDirPath + (NSString *)sharedDataAttachmentsDirPath
{ {
return [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"Attachments"]; return [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"Attachments"];
} }
+ (void)migrateToSharedData + (void)migrateToSharedData
{ {
[OWSFileSystem moveAppFilePath:self.oldAttachmentsDirPath [OWSFileSystem moveAppFilePath:self.legacyAttachmentsDirPath
sharedDataFilePath:self.newAttachmentsDirPath sharedDataFilePath:self.sharedDataAttachmentsDirPath
exceptionName:@"CouldNotMigrateAttachmentsDirectory"]; exceptionName:@"CouldNotMigrateAttachmentsDirectory"];
} }
@ -202,7 +202,7 @@ NS_ASSUME_NONNULL_BEGIN
static NSString *attachmentsFolder = nil; static NSString *attachmentsFolder = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
attachmentsFolder = TSAttachmentStream.newAttachmentsDirPath; attachmentsFolder = TSAttachmentStream.sharedDataAttachmentsDirPath;
BOOL isDirectory; BOOL isDirectory;
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:attachmentsFolder isDirectory:&isDirectory]; BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:attachmentsFolder isDirectory:&isDirectory];

@ -360,12 +360,12 @@ void setDatabaseInitialized()
{ {
// The old database location was in the Document directory, // The old database location was in the Document directory,
// so protect the database files individually. // so protect the database files individually.
[OWSFileSystem protectFolderAtPath:[self oldDatabaseFilePath]]; [OWSFileSystem protectFolderAtPath:self.legacyDatabaseFilePath];
[OWSFileSystem protectFolderAtPath:[self oldDatabaseFilePath_SHM]]; [OWSFileSystem protectFolderAtPath:self.legacyDatabaseFilePath_SHM];
[OWSFileSystem protectFolderAtPath:[self oldDatabaseFilePath_WAL]]; [OWSFileSystem protectFolderAtPath:self.legacyDatabaseFilePath_WAL];
// Protect the entire new database directory. // Protect the entire new database directory.
[OWSFileSystem protectFolderAtPath:[self newDatabaseDirPath]]; [OWSFileSystem protectFolderAtPath:self.sharedDataDatabaseDirPath];
} }
- (nullable YapDatabaseConnection *)newDatabaseConnection - (nullable YapDatabaseConnection *)newDatabaseConnection
@ -377,12 +377,12 @@ void setDatabaseInitialized()
return FALSE; return FALSE;
} }
+ (NSString *)oldDatabaseDirPath + (NSString *)legacyDatabaseDirPath
{ {
return [OWSFileSystem appDocumentDirectoryPath]; return [OWSFileSystem appDocumentDirectoryPath];
} }
+ (NSString *)newDatabaseDirPath + (NSString *)sharedDataDatabaseDirPath
{ {
NSString *databaseDirPath = [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"database"]; NSString *databaseDirPath = [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"database"];
@ -422,54 +422,54 @@ void setDatabaseInitialized()
return [self.databaseFilename stringByAppendingString:@"-wal"]; return [self.databaseFilename stringByAppendingString:@"-wal"];
} }
+ (NSString *)oldDatabaseFilePath + (NSString *)legacyDatabaseFilePath
{ {
return [self.oldDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename]; return [self.legacyDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename];
} }
+ (NSString *)oldDatabaseFilePath_SHM + (NSString *)legacyDatabaseFilePath_SHM
{ {
return [self.oldDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_SHM]; return [self.legacyDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_SHM];
} }
+ (NSString *)oldDatabaseFilePath_WAL + (NSString *)legacyDatabaseFilePath_WAL
{ {
return [self.oldDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_WAL]; return [self.legacyDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_WAL];
} }
+ (NSString *)newDatabaseFilePath + (NSString *)sharedDataDatabaseFilePath
{ {
return [self.newDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename]; return [self.sharedDataDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename];
} }
+ (NSString *)newDatabaseFilePath_SHM + (NSString *)sharedDataDatabaseFilePath_SHM
{ {
return [self.newDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_SHM]; return [self.sharedDataDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_SHM];
} }
+ (NSString *)newDatabaseFilePath_WAL + (NSString *)sharedDataDatabaseFilePath_WAL
{ {
return [self.newDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_WAL]; return [self.sharedDataDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_WAL];
} }
+ (void)migrateToSharedData + (void)migrateToSharedData
{ {
[OWSFileSystem moveAppFilePath:self.oldDatabaseFilePath [OWSFileSystem moveAppFilePath:self.legacyDatabaseFilePath
sharedDataFilePath:self.newDatabaseFilePath sharedDataFilePath:self.sharedDataDatabaseFilePath
exceptionName:TSStorageManagerExceptionName_CouldNotMoveDatabaseFile]; exceptionName:TSStorageManagerExceptionName_CouldNotMoveDatabaseFile];
[OWSFileSystem moveAppFilePath:self.oldDatabaseFilePath_SHM [OWSFileSystem moveAppFilePath:self.legacyDatabaseFilePath_SHM
sharedDataFilePath:self.newDatabaseFilePath_SHM sharedDataFilePath:self.sharedDataDatabaseFilePath_SHM
exceptionName:TSStorageManagerExceptionName_CouldNotMoveDatabaseFile]; exceptionName:TSStorageManagerExceptionName_CouldNotMoveDatabaseFile];
[OWSFileSystem moveAppFilePath:self.oldDatabaseFilePath_WAL [OWSFileSystem moveAppFilePath:self.legacyDatabaseFilePath_WAL
sharedDataFilePath:self.newDatabaseFilePath_WAL sharedDataFilePath:self.sharedDataDatabaseFilePath_WAL
exceptionName:TSStorageManagerExceptionName_CouldNotMoveDatabaseFile]; exceptionName:TSStorageManagerExceptionName_CouldNotMoveDatabaseFile];
} }
- (NSString *)dbPath - (NSString *)dbPath
{ {
DDLogVerbose(@"databasePath: %@", TSStorageManager.newDatabaseFilePath); DDLogVerbose(@"databasePath: %@", TSStorageManager.sharedDataDatabaseFilePath);
return TSStorageManager.newDatabaseFilePath; return TSStorageManager.sharedDataDatabaseFilePath;
} }
+ (BOOL)isDatabasePasswordAccessible + (BOOL)isDatabasePasswordAccessible

@ -28,9 +28,17 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)removeAll + (void)removeAll
{ {
NSString *appDomain = NSBundle.mainBundle.bundleIdentifier; [NSUserDefaults.standardUserDefaults removeAll];
[NSUserDefaults.standardUserDefaults removePersistentDomainForName:appDomain]; [self.appUserDefaults removeAll];
// TODO: How to clear the shared user defaults? }
- (void)removeAll
{
NSDictionary<NSString *, id> *dictionary = self.dictionaryRepresentation;
for (NSString *key in dictionary) {
[self removeObjectForKey:key];
}
[self synchronize];
} }
@end @end

Loading…
Cancel
Save