Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent 3de9a4ea55
commit 0d5b5bc44c

@ -80,9 +80,9 @@ NS_ASSUME_NONNULL_BEGIN
actionBlock:^{ actionBlock:^{
[DebugUISessionState clearSessionAndIdentityStore]; [DebugUISessionState clearSessionAndIdentityStore];
}], }],
[OWSTableItem itemWithTitle:@"Archive Session and Identity Store" [OWSTableItem itemWithTitle:@"Snapshot Session and Identity Store"
actionBlock:^{ actionBlock:^{
[DebugUISessionState archiveSessionAndIdentityStore]; [DebugUISessionState snapshotSessionAndIdentityStore];
}], }],
[OWSTableItem itemWithTitle:@"Restore Session and Identity Store" [OWSTableItem itemWithTitle:@"Restore Session and Identity Store"
actionBlock:^{ actionBlock:^{
@ -105,12 +105,12 @@ NS_ASSUME_NONNULL_BEGIN
}); });
} }
+ (void)archiveSessionAndIdentityStore + (void)snapshotSessionAndIdentityStore
{ {
dispatch_async([OWSDispatch sessionStoreQueue], ^{ dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager] archiveSessionStore]; [[TSStorageManager sharedManager] snapshotSessionStore];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[[OWSIdentityManager sharedManager] archiveIdentityState]; [[OWSIdentityManager sharedManager] snapshotIdentityState];
}); });
}); });
} }

@ -16,6 +16,10 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
// Hide the "import" directories from exports, etc. by prefixing their name with a period. // Hide the "import" directories from exports, etc. by prefixing their name with a period.
//
// OWSBackup backs up files and directories in the "app documents" and "shared data container",
// but ignores any top-level files or directories in those locations whose names start with a
// period ".".
NSString *const OWSBackup_DirNamePrefix = @".SignalBackup."; NSString *const OWSBackup_DirNamePrefix = @".SignalBackup.";
NSString *const OWSBackup_FileExtension = @".signalbackup"; NSString *const OWSBackup_FileExtension = @".signalbackup";
NSString *const OWSBackup_EncryptionKeyFilename = @".encryptionKey"; NSString *const OWSBackup_EncryptionKeyFilename = @".encryptionKey";

@ -53,8 +53,10 @@ extern const NSUInteger kIdentityKeyLength;
#pragma mark - Debug #pragma mark - Debug
#if DEBUG #if DEBUG
// Clears everything except the local identity key.
- (void)clearIdentityState; - (void)clearIdentityState;
- (void)archiveIdentityState;
- (void)snapshotIdentityState;
- (void)restoreIdentityState; - (void)restoreIdentityState;
#endif #endif

@ -771,17 +771,19 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
- (NSString *)identityKeySnapshotFilePath - (NSString *)identityKeySnapshotFilePath
{ {
// Prefix name with period "." so that backups will ignore these snapshots.
NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath]; NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath];
return [dirPath stringByAppendingPathComponent:@".identity-key-snapshot"]; return [dirPath stringByAppendingPathComponent:@".identity-key-snapshot"];
} }
- (NSString *)trustedKeySnapshotFilePath - (NSString *)trustedKeySnapshotFilePath
{ {
// Prefix name with period "." so that backups will ignore these snapshots.
NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath]; NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath];
return [dirPath stringByAppendingPathComponent:@".trusted-key-snapshot"]; return [dirPath stringByAppendingPathComponent:@".trusted-key-snapshot"];
} }
- (void)archiveIdentityState - (void)snapshotIdentityState
{ {
[self.dbConnection snapshotCollection:TSStorageManagerIdentityKeyStoreCollection [self.dbConnection snapshotCollection:TSStorageManagerIdentityKeyStoreCollection
snapshotFilePath:self.identityKeySnapshotFilePath]; snapshotFilePath:self.identityKeySnapshotFilePath];

@ -13,7 +13,7 @@
- (void)resetSessionStore; - (void)resetSessionStore;
#if DEBUG #if DEBUG
- (void)archiveSessionStore; - (void)snapshotSessionStore;
- (void)restoreSessionStore; - (void)restoreSessionStore;
#endif #endif
- (void)printAllSessions; - (void)printAllSessions;

@ -194,6 +194,8 @@ void AssertIsOnSessionStoreQueue()
- (void)resetSessionStore - (void)resetSessionStore
{ {
AssertIsOnSessionStoreQueue();
DDLogWarn(@"%@ resetting session store", self.logTag); DDLogWarn(@"%@ resetting session store", self.logTag);
[self.sessionDBConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { [self.sessionDBConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[transaction removeAllObjectsInCollection:TSStorageManagerSessionStoreCollection]; [transaction removeAllObjectsInCollection:TSStorageManagerSessionStoreCollection];
@ -247,11 +249,12 @@ void AssertIsOnSessionStoreQueue()
#if DEBUG #if DEBUG
- (NSString *)snapshotFilePath - (NSString *)snapshotFilePath
{ {
// Prefix name with period "." so that backups will ignore these snapshots.
NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath]; NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath];
return [dirPath stringByAppendingPathComponent:@".session-snapshot"]; return [dirPath stringByAppendingPathComponent:@".session-snapshot"];
} }
- (void)archiveSessionStore - (void)snapshotSessionStore
{ {
AssertIsOnSessionStoreQueue(); AssertIsOnSessionStoreQueue();

Loading…
Cancel
Save