diff --git a/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m b/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m index cbf1eba72..2c1058192 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m @@ -80,9 +80,9 @@ NS_ASSUME_NONNULL_BEGIN actionBlock:^{ [DebugUISessionState clearSessionAndIdentityStore]; }], - [OWSTableItem itemWithTitle:@"Archive Session and Identity Store" + [OWSTableItem itemWithTitle:@"Snapshot Session and Identity Store" actionBlock:^{ - [DebugUISessionState archiveSessionAndIdentityStore]; + [DebugUISessionState snapshotSessionAndIdentityStore]; }], [OWSTableItem itemWithTitle:@"Restore Session and Identity Store" actionBlock:^{ @@ -105,12 +105,12 @@ NS_ASSUME_NONNULL_BEGIN }); } -+ (void)archiveSessionAndIdentityStore ++ (void)snapshotSessionAndIdentityStore { dispatch_async([OWSDispatch sessionStoreQueue], ^{ - [[TSStorageManager sharedManager] archiveSessionStore]; + [[TSStorageManager sharedManager] snapshotSessionStore]; dispatch_async(dispatch_get_main_queue(), ^{ - [[OWSIdentityManager sharedManager] archiveIdentityState]; + [[OWSIdentityManager sharedManager] snapshotIdentityState]; }); }); } diff --git a/Signal/src/util/OWSBackup.m b/Signal/src/util/OWSBackup.m index b0ce065a9..e61c44647 100644 --- a/Signal/src/util/OWSBackup.m +++ b/Signal/src/util/OWSBackup.m @@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN // 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_FileExtension = @".signalbackup"; NSString *const OWSBackup_EncryptionKeyFilename = @".encryptionKey"; diff --git a/SignalServiceKit/src/Messages/OWSIdentityManager.h b/SignalServiceKit/src/Messages/OWSIdentityManager.h index 2cde37f43..4a5e1fb8f 100644 --- a/SignalServiceKit/src/Messages/OWSIdentityManager.h +++ b/SignalServiceKit/src/Messages/OWSIdentityManager.h @@ -53,8 +53,10 @@ extern const NSUInteger kIdentityKeyLength; #pragma mark - Debug #if DEBUG +// Clears everything except the local identity key. - (void)clearIdentityState; -- (void)archiveIdentityState; + +- (void)snapshotIdentityState; - (void)restoreIdentityState; #endif diff --git a/SignalServiceKit/src/Messages/OWSIdentityManager.m b/SignalServiceKit/src/Messages/OWSIdentityManager.m index 7a6132665..4e2e20cef 100644 --- a/SignalServiceKit/src/Messages/OWSIdentityManager.m +++ b/SignalServiceKit/src/Messages/OWSIdentityManager.m @@ -771,17 +771,19 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa - (NSString *)identityKeySnapshotFilePath { + // Prefix name with period "." so that backups will ignore these snapshots. NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath]; return [dirPath stringByAppendingPathComponent:@".identity-key-snapshot"]; } - (NSString *)trustedKeySnapshotFilePath { + // Prefix name with period "." so that backups will ignore these snapshots. NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath]; return [dirPath stringByAppendingPathComponent:@".trusted-key-snapshot"]; } -- (void)archiveIdentityState +- (void)snapshotIdentityState { [self.dbConnection snapshotCollection:TSStorageManagerIdentityKeyStoreCollection snapshotFilePath:self.identityKeySnapshotFilePath]; diff --git a/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.h b/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.h index 4bec5de02..2e1cf67b3 100644 --- a/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.h +++ b/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.h @@ -13,7 +13,7 @@ - (void)resetSessionStore; #if DEBUG -- (void)archiveSessionStore; +- (void)snapshotSessionStore; - (void)restoreSessionStore; #endif - (void)printAllSessions; diff --git a/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m b/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m index 0d6d96263..d90e719e8 100644 --- a/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m +++ b/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m @@ -194,6 +194,8 @@ void AssertIsOnSessionStoreQueue() - (void)resetSessionStore { + AssertIsOnSessionStoreQueue(); + DDLogWarn(@"%@ resetting session store", self.logTag); [self.sessionDBConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { [transaction removeAllObjectsInCollection:TSStorageManagerSessionStoreCollection]; @@ -247,11 +249,12 @@ void AssertIsOnSessionStoreQueue() #if DEBUG - (NSString *)snapshotFilePath { + // Prefix name with period "." so that backups will ignore these snapshots. NSString *dirPath = [OWSFileSystem appDocumentDirectoryPath]; return [dirPath stringByAppendingPathComponent:@".session-snapshot"]; } -- (void)archiveSessionStore +- (void)snapshotSessionStore { AssertIsOnSessionStoreQueue();