Skip to content

Commit 509d2d0

Browse files
committed
Merge branch 'charlesmchen/attachmentStreamUpgradePerf'
2 parents f6f5d3d + f3f8325 commit 509d2d0

File tree

6 files changed

+86
-7
lines changed

6 files changed

+86
-7
lines changed

Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ CHECKOUT OPTIONS:
134134
:commit: 521686c112bbae7a762f85d52b1e41eeb1760772
135135
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
136136
SignalServiceKit:
137-
:commit: ed249840c61ab48a7fcd762d7d4b01dc78dff0a6
137+
:commit: 2315ab79de5fad39c3a285ff74d2fc8d62211eab
138138
:git: https://github.com/WhisperSystems/SignalServiceKit.git
139139
SocketRocket:
140140
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf

Signal.xcodeproj/project.pbxproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
340CB2271EAC25820001CAA1 /* UpdateGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340CB2261EAC25820001CAA1 /* UpdateGroupViewController.m */; };
1515
341207271EE19F6A00463194 /* OWSSystemMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 341207261EE19F6A00463194 /* OWSSystemMessageCell.m */; };
1616
341BB7491DB727EE001E2975 /* JSQMediaItem+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 341BB7481DB727EE001E2975 /* JSQMediaItem+OWS.m */; };
17+
342FCE6B1EF9C375002690AD /* OWS105AttachmentFilePaths.m in Sources */ = {isa = PBXBuildFile; fileRef = 342FCE6A1EF9C375002690AD /* OWS105AttachmentFilePaths.m */; };
1718
34330A5A1E7875FB00DF2FB9 /* fontawesome-webfont.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A591E7875FB00DF2FB9 /* fontawesome-webfont.ttf */; };
1819
34330A5C1E787A9800DF2FB9 /* dripicons-v2.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5B1E787A9800DF2FB9 /* dripicons-v2.ttf */; };
1920
34330A5E1E787BD800DF2FB9 /* ElegantIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5D1E787BD800DF2FB9 /* ElegantIcons.ttf */; };
@@ -376,6 +377,8 @@
376377
341207261EE19F6A00463194 /* OWSSystemMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = OWSSystemMessageCell.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
377378
341BB7471DB727EE001E2975 /* JSQMediaItem+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSQMediaItem+OWS.h"; sourceTree = "<group>"; };
378379
341BB7481DB727EE001E2975 /* JSQMediaItem+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSQMediaItem+OWS.m"; sourceTree = "<group>"; };
380+
342FCE691EF9C375002690AD /* OWS105AttachmentFilePaths.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWS105AttachmentFilePaths.h; path = Migrations/OWS105AttachmentFilePaths.h; sourceTree = "<group>"; };
381+
342FCE6A1EF9C375002690AD /* OWS105AttachmentFilePaths.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWS105AttachmentFilePaths.m; path = Migrations/OWS105AttachmentFilePaths.m; sourceTree = "<group>"; };
379382
34330A591E7875FB00DF2FB9 /* fontawesome-webfont.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "fontawesome-webfont.ttf"; sourceTree = "<group>"; };
380383
34330A5B1E787A9800DF2FB9 /* dripicons-v2.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "dripicons-v2.ttf"; sourceTree = "<group>"; };
381384
34330A5D1E787BD800DF2FB9 /* ElegantIcons.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = ElegantIcons.ttf; sourceTree = "<group>"; };
@@ -1093,10 +1096,6 @@
10931096
45666F731D9BFDB9008FE134 /* Migrations */ = {
10941097
isa = PBXGroup;
10951098
children = (
1096-
45666F791D9C0533008FE134 /* OWSDatabaseMigration.h */,
1097-
45666F7A1D9C0533008FE134 /* OWSDatabaseMigration.m */,
1098-
45666F7C1D9C0814008FE134 /* OWSDatabaseMigrationRunner.h */,
1099-
45666F7D1D9C0814008FE134 /* OWSDatabaseMigrationRunner.m */,
11001099
45666F741D9BFE00008FE134 /* OWS100RemoveTSRecipientsMigration.h */,
11011100
45666F751D9BFE00008FE134 /* OWS100RemoveTSRecipientsMigration.m */,
11021101
4516E3FD1DD2193B00DC4206 /* OWS101ExistingUsersBlockOnIdentityChange.h */,
@@ -1107,6 +1106,12 @@
11071106
450573FD1E78A06D00615BB4 /* OWS103EnableVideoCalling.m */,
11081107
4585C45E1ED4FD0400896AEA /* OWS104CreateRecipientIdentities.h */,
11091108
4585C45F1ED4FD0400896AEA /* OWS104CreateRecipientIdentities.m */,
1109+
342FCE691EF9C375002690AD /* OWS105AttachmentFilePaths.h */,
1110+
342FCE6A1EF9C375002690AD /* OWS105AttachmentFilePaths.m */,
1111+
45666F791D9C0533008FE134 /* OWSDatabaseMigration.h */,
1112+
45666F7A1D9C0533008FE134 /* OWSDatabaseMigration.m */,
1113+
45666F7C1D9C0814008FE134 /* OWSDatabaseMigrationRunner.h */,
1114+
45666F7D1D9C0814008FE134 /* OWSDatabaseMigrationRunner.m */,
11101115
);
11111116
name = Migrations;
11121117
sourceTree = "<group>";
@@ -2117,6 +2122,7 @@
21172122
76EB057A18170B33006006FC /* OWSContactsManager.m in Sources */,
21182123
76EB064218170B33006006FC /* StringUtil.m in Sources */,
21192124
452037D11EE84975004E4CDF /* DebugUISessionState.m in Sources */,
2125+
342FCE6B1EF9C375002690AD /* OWS105AttachmentFilePaths.m in Sources */,
21202126
45BFFFA81D898AF0004A12A7 /* OWSStaleNotificationObserver.m in Sources */,
21212127
45C681B71D305A580050903A /* OWSCall.m in Sources */,
21222128
76EB062618170B33006006FC /* Queue.m in Sources */,

Signal/src/environment/Migrations/OWS102MoveLoggingPreferenceToUserDefaults.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ - (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
4141
}
4242
}
4343

44-
4544
#pragma mark - Logging
4645

4746
+ (NSString *)tag
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
3+
//
4+
5+
#import "OWSDatabaseMigration.h"
6+
7+
NS_ASSUME_NONNULL_BEGIN
8+
9+
@interface OWS105AttachmentFilePaths : OWSDatabaseMigration
10+
11+
@end
12+
13+
NS_ASSUME_NONNULL_END
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
3+
//
4+
5+
#import "OWS105AttachmentFilePaths.h"
6+
#import <SignalServiceKit/TSAttachmentStream.h>
7+
#import <YapDatabase/YapDatabaseTransaction.h>
8+
9+
NS_ASSUME_NONNULL_BEGIN
10+
11+
// Increment a similar constant for every future DBMigration
12+
static NSString *const OWS105AttachmentFilePathsMigrationId = @"105";
13+
14+
@implementation OWS105AttachmentFilePaths
15+
16+
+ (NSString *)migrationId
17+
{
18+
return OWS105AttachmentFilePathsMigrationId;
19+
}
20+
21+
- (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
22+
{
23+
OWSAssert(transaction);
24+
25+
NSMutableArray<TSAttachmentStream *> *attachmentStreams = [NSMutableArray new];
26+
[transaction enumerateKeysAndObjectsInCollection:TSAttachmentStream.collection
27+
usingBlock:^(NSString *key, TSAttachment *attachment, BOOL *stop) {
28+
if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
29+
return;
30+
}
31+
TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment;
32+
[attachmentStreams addObject:attachmentStream];
33+
}];
34+
35+
DDLogInfo(@"Saving %zd attachment streams.", attachmentStreams.count);
36+
37+
// Persist the new localRelativeFilePath property of TSAttachmentStream.
38+
// For performance, we want to upgrade all existing attachment streams in
39+
// a single transaction.
40+
for (TSAttachmentStream *attachmentStream in attachmentStreams) {
41+
[attachmentStream saveWithTransaction:transaction];
42+
}
43+
}
44+
45+
#pragma mark - Logging
46+
47+
+ (NSString *)tag
48+
{
49+
return [NSString stringWithFormat:@"[%@]", self.class];
50+
}
51+
52+
- (NSString *)tag
53+
{
54+
return self.class.tag;
55+
}
56+
57+
@end
58+
59+
NS_ASSUME_NONNULL_END

Signal/src/environment/Migrations/OWSDatabaseMigrationRunner.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#import "OWS102MoveLoggingPreferenceToUserDefaults.h"
88
#import "OWS103EnableVideoCalling.h"
99
#import "OWS104CreateRecipientIdentities.h"
10+
#import "OWS105AttachmentFilePaths.h"
1011

1112
NS_ASSUME_NONNULL_BEGIN
1213

@@ -30,7 +31,8 @@ - (instancetype)initWithStorageManager:(TSStorageManager *)storageManager
3031
[[OWS100RemoveTSRecipientsMigration alloc] initWithStorageManager:self.storageManager],
3132
[[OWS102MoveLoggingPreferenceToUserDefaults alloc] initWithStorageManager:self.storageManager],
3233
[[OWS103EnableVideoCalling alloc] initWithStorageManager:self.storageManager],
33-
[[OWS104CreateRecipientIdentities alloc] initWithStorageManager:self.storageManager]
34+
[[OWS104CreateRecipientIdentities alloc] initWithStorageManager:self.storageManager],
35+
[[OWS105AttachmentFilePaths alloc] initWithStorageManager:self.storageManager]
3436
];
3537
}
3638

0 commit comments

Comments
 (0)