diff --git a/Podfile.lock b/Podfile.lock index 39689314a..df4b8d03c 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -134,7 +134,7 @@ CHECKOUT OPTIONS: :commit: 521686c112bbae7a762f85d52b1e41eeb1760772 :git: https://github.com/WhisperSystems/JSQMessagesViewController.git SignalServiceKit: - :commit: ed249840c61ab48a7fcd762d7d4b01dc78dff0a6 + :commit: 2315ab79de5fad39c3a285ff74d2fc8d62211eab :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 0706ac717..26f18ea80 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 340CB2271EAC25820001CAA1 /* UpdateGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340CB2261EAC25820001CAA1 /* UpdateGroupViewController.m */; }; 341207271EE19F6A00463194 /* OWSSystemMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 341207261EE19F6A00463194 /* OWSSystemMessageCell.m */; }; 341BB7491DB727EE001E2975 /* JSQMediaItem+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 341BB7481DB727EE001E2975 /* JSQMediaItem+OWS.m */; }; + 342FCE6B1EF9C375002690AD /* OWS105AttachmentFilePaths.m in Sources */ = {isa = PBXBuildFile; fileRef = 342FCE6A1EF9C375002690AD /* OWS105AttachmentFilePaths.m */; }; 34330A5A1E7875FB00DF2FB9 /* fontawesome-webfont.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A591E7875FB00DF2FB9 /* fontawesome-webfont.ttf */; }; 34330A5C1E787A9800DF2FB9 /* dripicons-v2.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5B1E787A9800DF2FB9 /* dripicons-v2.ttf */; }; 34330A5E1E787BD800DF2FB9 /* ElegantIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5D1E787BD800DF2FB9 /* ElegantIcons.ttf */; }; @@ -376,6 +377,8 @@ 341207261EE19F6A00463194 /* OWSSystemMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = OWSSystemMessageCell.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 341BB7471DB727EE001E2975 /* JSQMediaItem+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSQMediaItem+OWS.h"; sourceTree = ""; }; 341BB7481DB727EE001E2975 /* JSQMediaItem+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSQMediaItem+OWS.m"; sourceTree = ""; }; + 342FCE691EF9C375002690AD /* OWS105AttachmentFilePaths.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWS105AttachmentFilePaths.h; path = Migrations/OWS105AttachmentFilePaths.h; sourceTree = ""; }; + 342FCE6A1EF9C375002690AD /* OWS105AttachmentFilePaths.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWS105AttachmentFilePaths.m; path = Migrations/OWS105AttachmentFilePaths.m; sourceTree = ""; }; 34330A591E7875FB00DF2FB9 /* fontawesome-webfont.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "fontawesome-webfont.ttf"; sourceTree = ""; }; 34330A5B1E787A9800DF2FB9 /* dripicons-v2.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "dripicons-v2.ttf"; sourceTree = ""; }; 34330A5D1E787BD800DF2FB9 /* ElegantIcons.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = ElegantIcons.ttf; sourceTree = ""; }; @@ -1093,10 +1096,6 @@ 45666F731D9BFDB9008FE134 /* Migrations */ = { isa = PBXGroup; children = ( - 45666F791D9C0533008FE134 /* OWSDatabaseMigration.h */, - 45666F7A1D9C0533008FE134 /* OWSDatabaseMigration.m */, - 45666F7C1D9C0814008FE134 /* OWSDatabaseMigrationRunner.h */, - 45666F7D1D9C0814008FE134 /* OWSDatabaseMigrationRunner.m */, 45666F741D9BFE00008FE134 /* OWS100RemoveTSRecipientsMigration.h */, 45666F751D9BFE00008FE134 /* OWS100RemoveTSRecipientsMigration.m */, 4516E3FD1DD2193B00DC4206 /* OWS101ExistingUsersBlockOnIdentityChange.h */, @@ -1107,6 +1106,12 @@ 450573FD1E78A06D00615BB4 /* OWS103EnableVideoCalling.m */, 4585C45E1ED4FD0400896AEA /* OWS104CreateRecipientIdentities.h */, 4585C45F1ED4FD0400896AEA /* OWS104CreateRecipientIdentities.m */, + 342FCE691EF9C375002690AD /* OWS105AttachmentFilePaths.h */, + 342FCE6A1EF9C375002690AD /* OWS105AttachmentFilePaths.m */, + 45666F791D9C0533008FE134 /* OWSDatabaseMigration.h */, + 45666F7A1D9C0533008FE134 /* OWSDatabaseMigration.m */, + 45666F7C1D9C0814008FE134 /* OWSDatabaseMigrationRunner.h */, + 45666F7D1D9C0814008FE134 /* OWSDatabaseMigrationRunner.m */, ); name = Migrations; sourceTree = ""; @@ -2117,6 +2122,7 @@ 76EB057A18170B33006006FC /* OWSContactsManager.m in Sources */, 76EB064218170B33006006FC /* StringUtil.m in Sources */, 452037D11EE84975004E4CDF /* DebugUISessionState.m in Sources */, + 342FCE6B1EF9C375002690AD /* OWS105AttachmentFilePaths.m in Sources */, 45BFFFA81D898AF0004A12A7 /* OWSStaleNotificationObserver.m in Sources */, 45C681B71D305A580050903A /* OWSCall.m in Sources */, 76EB062618170B33006006FC /* Queue.m in Sources */, diff --git a/Signal/src/environment/Migrations/OWS102MoveLoggingPreferenceToUserDefaults.m b/Signal/src/environment/Migrations/OWS102MoveLoggingPreferenceToUserDefaults.m index f7935506c..d80c2e70a 100644 --- a/Signal/src/environment/Migrations/OWS102MoveLoggingPreferenceToUserDefaults.m +++ b/Signal/src/environment/Migrations/OWS102MoveLoggingPreferenceToUserDefaults.m @@ -41,7 +41,6 @@ static NSString *const OWS102MoveLoggingPreferenceToUserDefaultsMigrationId = @" } } - #pragma mark - Logging + (NSString *)tag diff --git a/Signal/src/environment/Migrations/OWS105AttachmentFilePaths.h b/Signal/src/environment/Migrations/OWS105AttachmentFilePaths.h new file mode 100644 index 000000000..a9fbfb6d1 --- /dev/null +++ b/Signal/src/environment/Migrations/OWS105AttachmentFilePaths.h @@ -0,0 +1,13 @@ +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// + +#import "OWSDatabaseMigration.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OWS105AttachmentFilePaths : OWSDatabaseMigration + +@end + +NS_ASSUME_NONNULL_END diff --git a/Signal/src/environment/Migrations/OWS105AttachmentFilePaths.m b/Signal/src/environment/Migrations/OWS105AttachmentFilePaths.m new file mode 100644 index 000000000..f096e3ae8 --- /dev/null +++ b/Signal/src/environment/Migrations/OWS105AttachmentFilePaths.m @@ -0,0 +1,59 @@ +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// + +#import "OWS105AttachmentFilePaths.h" +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +// Increment a similar constant for every future DBMigration +static NSString *const OWS105AttachmentFilePathsMigrationId = @"105"; + +@implementation OWS105AttachmentFilePaths + ++ (NSString *)migrationId +{ + return OWS105AttachmentFilePathsMigrationId; +} + +- (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction +{ + OWSAssert(transaction); + + NSMutableArray *attachmentStreams = [NSMutableArray new]; + [transaction enumerateKeysAndObjectsInCollection:TSAttachmentStream.collection + usingBlock:^(NSString *key, TSAttachment *attachment, BOOL *stop) { + if (![attachment isKindOfClass:[TSAttachmentStream class]]) { + return; + } + TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment; + [attachmentStreams addObject:attachmentStream]; + }]; + + DDLogInfo(@"Saving %zd attachment streams.", attachmentStreams.count); + + // Persist the new localRelativeFilePath property of TSAttachmentStream. + // For performance, we want to upgrade all existing attachment streams in + // a single transaction. + for (TSAttachmentStream *attachmentStream in attachmentStreams) { + [attachmentStream saveWithTransaction:transaction]; + } +} + +#pragma mark - Logging + ++ (NSString *)tag +{ + return [NSString stringWithFormat:@"[%@]", self.class]; +} + +- (NSString *)tag +{ + return self.class.tag; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/Signal/src/environment/Migrations/OWSDatabaseMigrationRunner.m b/Signal/src/environment/Migrations/OWSDatabaseMigrationRunner.m index d3a0434f4..d2a6c6d07 100644 --- a/Signal/src/environment/Migrations/OWSDatabaseMigrationRunner.m +++ b/Signal/src/environment/Migrations/OWSDatabaseMigrationRunner.m @@ -7,6 +7,7 @@ #import "OWS102MoveLoggingPreferenceToUserDefaults.h" #import "OWS103EnableVideoCalling.h" #import "OWS104CreateRecipientIdentities.h" +#import "OWS105AttachmentFilePaths.h" NS_ASSUME_NONNULL_BEGIN @@ -30,7 +31,8 @@ NS_ASSUME_NONNULL_BEGIN [[OWS100RemoveTSRecipientsMigration alloc] initWithStorageManager:self.storageManager], [[OWS102MoveLoggingPreferenceToUserDefaults alloc] initWithStorageManager:self.storageManager], [[OWS103EnableVideoCalling alloc] initWithStorageManager:self.storageManager], - [[OWS104CreateRecipientIdentities alloc] initWithStorageManager:self.storageManager] + [[OWS104CreateRecipientIdentities alloc] initWithStorageManager:self.storageManager], + [[OWS105AttachmentFilePaths alloc] initWithStorageManager:self.storageManager] ]; }