From 9295a56309ffa59fbb256514ac622e21f50553ce Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 20 Feb 2018 16:25:15 -0500 Subject: [PATCH] Elaborate logging around storage migration. --- .../src/Storage/TSStorageManager.m | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/SignalServiceKit/src/Storage/TSStorageManager.m b/SignalServiceKit/src/Storage/TSStorageManager.m index 01fdceced..2692e7660 100644 --- a/SignalServiceKit/src/Storage/TSStorageManager.m +++ b/SignalServiceKit/src/Storage/TSStorageManager.m @@ -222,6 +222,23 @@ void runAsyncRegistrationsForStorage(OWSStorage *storage) + (void)migrateToSharedData { + // Given how sensitive this migration is, we verbosely + // log the contents of all involved paths before and after. + NSArray *paths = @[ + self.legacyDatabaseFilePath, + self.legacyDatabaseFilePath_SHM, + self.legacyDatabaseFilePath_WAL, + self.sharedDataDatabaseFilePath, + self.sharedDataDatabaseFilePath_SHM, + self.sharedDataDatabaseFilePath_WAL, + ]; + NSFileManager *fileManager = [NSFileManager defaultManager]; + for (NSString *path in paths) { + if ([fileManager fileExistsAtPath:path]) { + DDLogInfo(@"%@ migrateToSharedData before %@: %@", self.logTag, path, [OWSFileSystem fileSizeOfPath:path]); + } + } + // We protect the db files here, which is somewhat redundant with what will happen in // `moveAppFilePath:` which also ensures file protection. // However that method dispatches async, since it can take a while with large attachment directories. @@ -244,6 +261,12 @@ void runAsyncRegistrationsForStorage(OWSStorage *storage) [OWSFileSystem moveAppFilePath:self.legacyDatabaseFilePath_WAL sharedDataFilePath:self.sharedDataDatabaseFilePath_WAL exceptionName:TSStorageManagerExceptionName_CouldNotMoveDatabaseFile]; + + for (NSString *path in paths) { + if ([fileManager fileExistsAtPath:path]) { + DDLogInfo(@"%@ migrateToSharedData after %@: %@", self.logTag, path, [OWSFileSystem fileSizeOfPath:path]); + } + } } + (NSString *)databaseFilePath