Modify TSStorageManager to use separate shared read and write connections.
// FREEBIE
This commit is contained in:
parent
906b307e1f
commit
7135895c1c
4
Podfile
4
Podfile
@ -5,8 +5,8 @@ target 'Signal' do
|
||||
pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git'
|
||||
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git'
|
||||
#pod 'AxolotlKit', path: '../SignalProtocolKit'
|
||||
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
|
||||
#pod 'SignalServiceKit', path: '../SignalServiceKit'
|
||||
#pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
|
||||
pod 'SignalServiceKit', path: '../SignalServiceKit'
|
||||
pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/retain-keyboard-view'
|
||||
#pod 'JSQMessagesViewController', path: '../JSQMessagesViewController'
|
||||
pod 'PureLayout'
|
||||
|
||||
@ -112,7 +112,7 @@ DEPENDENCIES:
|
||||
- JSQMessagesViewController (from `https://github.com/WhisperSystems/JSQMessagesViewController.git`, branch `mkirk/retain-keyboard-view`)
|
||||
- PureLayout
|
||||
- Reachability
|
||||
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`)
|
||||
- SignalServiceKit (from `../SignalServiceKit`)
|
||||
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
@ -122,7 +122,7 @@ EXTERNAL SOURCES:
|
||||
:branch: mkirk/retain-keyboard-view
|
||||
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
|
||||
SignalServiceKit:
|
||||
:git: https://github.com/WhisperSystems/SignalServiceKit.git
|
||||
:path: ../SignalServiceKit
|
||||
SocketRocket:
|
||||
:git: https://github.com/facebook/SocketRocket.git
|
||||
|
||||
@ -133,9 +133,6 @@ CHECKOUT OPTIONS:
|
||||
JSQMessagesViewController:
|
||||
:commit: 521686c112bbae7a762f85d52b1e41eeb1760772
|
||||
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
|
||||
SignalServiceKit:
|
||||
:commit: 04ef06ce95d553116d6b53984f0dcf9429ab78f4
|
||||
:git: https://github.com/WhisperSystems/SignalServiceKit.git
|
||||
SocketRocket:
|
||||
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf
|
||||
:git: https://github.com/facebook/SocketRocket.git
|
||||
@ -161,6 +158,6 @@ SPEC CHECKSUMS:
|
||||
UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d
|
||||
YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266
|
||||
|
||||
PODFILE CHECKSUM: 01734aea935bf91b25ee9aed90e20403075e5d19
|
||||
PODFILE CHECKSUM: 2088b6153dfaf0ce79fdf9141c7885c1ab84dd2b
|
||||
|
||||
COCOAPODS: 1.2.1
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++0BB03DB",
|
||||
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++2D5CBAE",
|
||||
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
|
||||
|
||||
},
|
||||
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
|
||||
"8176314449001F06FB0E5B588C62133EAA2FE911+++72E8629" : 9223372036854775807,
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++0BB03DB" : 0,
|
||||
"01DE8628B025BC69C8C7D8B4612D57BE2C08B62C+++6A1C9FC" : 0,
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++0BB03DB" : 0,
|
||||
"ABB939127996C66F7E852A780552ADEEF03C6B13+++69179A3" : 0,
|
||||
"90530B99EB0008E7A50951FDFBE02169118FA649+++EF2C0B3" : 0,
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++ED4C31A" : 0,
|
||||
"D74FB800F048CB516BB4BC70047F7CC676D291B9+++375B249" : 0,
|
||||
"8176314449001F06FB0E5B588C62133EAA2FE911+++692B8E4" : 9223372036854775807,
|
||||
"37054CE35CE656680D6FFFA9EE19249E0D149C5E+++901E7D4" : 0,
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++2D5CBAE" : 0,
|
||||
"8176314449001F06FB0E5B588C62133EAA2FE911+++E19D6E3" : 9223372036854775807,
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++03D0758" : 0,
|
||||
"37054CE35CE656680D6FFFA9EE19249E0D149C5E+++3F8B703" : 9223372036854775807,
|
||||
@ -21,13 +23,15 @@
|
||||
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "D0F297E7-A82D-4657-A941-96B268F80ABC",
|
||||
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
|
||||
"8176314449001F06FB0E5B588C62133EAA2FE911+++72E8629" : "Signal-iOS-2\/Carthage\/",
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++0BB03DB" : "Signal-iOS-2\/",
|
||||
"01DE8628B025BC69C8C7D8B4612D57BE2C08B62C+++6A1C9FC" : "SignalProtocolKit\/",
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++0BB03DB" : "Signal-iOS-2\/",
|
||||
"ABB939127996C66F7E852A780552ADEEF03C6B13+++69179A3" : "SocketRocket\/",
|
||||
"90530B99EB0008E7A50951FDFBE02169118FA649+++EF2C0B3" : "JSQMessagesViewController\/",
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++ED4C31A" : "Signal-iOS\/",
|
||||
"D74FB800F048CB516BB4BC70047F7CC676D291B9+++375B249" : "Signal-iOS\/Pods\/",
|
||||
"8176314449001F06FB0E5B588C62133EAA2FE911+++692B8E4" : "Signal-iOS-4\/Carthage\/",
|
||||
"37054CE35CE656680D6FFFA9EE19249E0D149C5E+++901E7D4" : "SignalServiceKit\/",
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++2D5CBAE" : "Signal-iOS-4\/",
|
||||
"8176314449001F06FB0E5B588C62133EAA2FE911+++E19D6E3" : "Signal-iOS\/Carthage\/",
|
||||
"5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++03D0758" : "Signal-iOS-5\/",
|
||||
"37054CE35CE656680D6FFFA9EE19249E0D149C5E+++3F8B703" : "SignalServiceKit-2\/",
|
||||
@ -68,6 +72,11 @@
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++0BB03DB"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:WhisperSystems\/Signal-iOS.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "5D79A077E31B3FE97A3C6613CBFFDD71C314D14C+++2D5CBAE"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:WhisperSystems\/Signal-iOS.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
@ -78,6 +87,11 @@
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8176314449001F06FB0E5B588C62133EAA2FE911+++31C7255"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/WhisperSystems\/Signal-Carthage.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8176314449001F06FB0E5B588C62133EAA2FE911+++692B8E4"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/WhisperSystems\/Signal-Carthage.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
|
||||
@ -278,7 +278,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
{
|
||||
if (!_nonSignalContacts) {
|
||||
NSMutableSet<Contact *> *nonSignalContacts = [NSMutableSet new];
|
||||
[[TSStorageManager sharedManager].dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
[[TSStorageManager sharedManager].dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
for (Contact *contact in self.contactsManager.allContactsMap.allValues) {
|
||||
NSArray<SignalRecipient *> *signalRecipients = [contact signalRecipientsWithTransaction:transaction];
|
||||
if (signalRecipients.count < 1) {
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
|
||||
__block NSUInteger threadCount;
|
||||
__block NSUInteger messageCount;
|
||||
[TSStorageManager.sharedManager.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
[TSStorageManager.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
threadCount = [[transaction ext:TSThreadDatabaseViewExtensionName] numberOfItemsInAllGroups];
|
||||
messageCount = [[transaction ext:TSMessageDatabaseViewExtensionName] numberOfItemsInAllGroups];
|
||||
}];
|
||||
|
||||
@ -575,7 +575,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NSMutableArray<TSInteraction *> *result = [NSMutableArray new];
|
||||
|
||||
[[TSStorageManager sharedManager].dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection readWriteWithBlock:^(
|
||||
YapDatabaseReadWriteTransaction *transaction) {
|
||||
|
||||
if ([thread isKindOfClass:[TSContactThread class]]) {
|
||||
TSContactThread *contactThread = (TSContactThread *)thread;
|
||||
@ -716,11 +717,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
OWSAssert(thread);
|
||||
|
||||
NSArray<TSInteraction *> *messages = [self unsavedSystemMessagesInThread:thread];
|
||||
[[TSStorageManager sharedManager].dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
for (TSInteraction *message in messages) {
|
||||
[message saveWithTransaction:transaction];
|
||||
}
|
||||
}];
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
for (TSInteraction *message in messages) {
|
||||
[message saveWithTransaction:transaction];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)createSystemMessageInThread:(TSThread *)thread
|
||||
@ -729,9 +731,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NSArray<TSInteraction *> *messages = [self unsavedSystemMessagesInThread:thread];
|
||||
TSInteraction *message = messages[(NSUInteger)arc4random_uniform((uint32_t)messages.count)];
|
||||
[[TSStorageManager sharedManager].dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[message saveWithTransaction:transaction];
|
||||
}];
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[message saveWithTransaction:transaction];
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)sendTextAndSystemMessages:(int)counter thread:(TSThread *)thread
|
||||
@ -790,7 +793,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (void)createFakeUnreadMessages:(int)counter thread:(TSThread *)thread
|
||||
{
|
||||
[TSStorageManager.sharedManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[TSStorageManager.sharedManager.dbReadWriteConnection readWriteWithBlock:^(
|
||||
YapDatabaseReadWriteTransaction *transaction) {
|
||||
for (int i = 0; i < counter; i++) {
|
||||
NSString *randomText = [self randomText];
|
||||
TSIncomingMessage *message = [[TSIncomingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
@ -805,7 +809,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (void)sendFakeMessages:(int)counter thread:(TSThread *)thread
|
||||
{
|
||||
[TSStorageManager.sharedManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[TSStorageManager.sharedManager.dbReadWriteConnection readWriteWithBlock:^(
|
||||
YapDatabaseReadWriteTransaction *transaction) {
|
||||
for (int i = 0; i < counter; i++) {
|
||||
NSString *randomText = [self randomText];
|
||||
switch (arc4random_uniform(4)) {
|
||||
|
||||
@ -444,7 +444,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
|
||||
TSGroupModel *model = [self makeGroup];
|
||||
|
||||
__block TSGroupThread *thread;
|
||||
[[TSStorageManager sharedManager].dbConnection
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
thread = [TSGroupThread getOrCreateThreadWithGroupModel:model transaction:transaction];
|
||||
}];
|
||||
|
||||
@ -215,9 +215,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
}
|
||||
|
||||
__block TSThread *thread = nil;
|
||||
[[TSStorageManager sharedManager].dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
thread = [TSContactThread getOrCreateThreadWithContactId:signalAccount.recipientId transaction:transaction];
|
||||
}];
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
thread = [TSContactThread getOrCreateThreadWithContactId:signalAccount.recipientId transaction:transaction];
|
||||
}];
|
||||
OWSAssert(thread);
|
||||
|
||||
[self.delegate threadWasSelected:thread];
|
||||
|
||||
@ -172,7 +172,7 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
|
||||
// in order to avoid database deadlock.
|
||||
NSMutableDictionary<NSString *, NSArray<SignalRecipient *> *> *contactIdToSignalRecipientsMap =
|
||||
[NSMutableDictionary new];
|
||||
[[TSStorageManager sharedManager].dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
[[TSStorageManager sharedManager].dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
for (Contact *contact in contacts) {
|
||||
NSArray<SignalRecipient *> *signalRecipients = [contact signalRecipientsWithTransaction:transaction];
|
||||
contactIdToSignalRecipientsMap[contact.uniqueId] = signalRecipients;
|
||||
|
||||
@ -209,11 +209,11 @@ static Environment *environment = nil;
|
||||
Environment *env = [self getCurrent];
|
||||
SignalsViewController *vc = env.signalsViewController;
|
||||
|
||||
[[TSStorageManager sharedManager]
|
||||
.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
TSThread *thread = [TSContactThread getOrCreateThreadWithContactId:identifier transaction:transaction];
|
||||
[vc presentThread:thread keyboardOnViewAppearing:YES callOnViewAppearing:NO];
|
||||
}];
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
TSThread *thread = [TSContactThread getOrCreateThreadWithContactId:identifier transaction:transaction];
|
||||
[vc presentThread:thread keyboardOnViewAppearing:YES callOnViewAppearing:NO];
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)callUserWithIdentifier:(NSString *)identifier
|
||||
@ -221,7 +221,7 @@ static Environment *environment = nil;
|
||||
Environment *env = [self getCurrent];
|
||||
SignalsViewController *vc = env.signalsViewController;
|
||||
|
||||
[[TSStorageManager sharedManager].dbConnection
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
TSThread *thread = [TSContactThread getOrCreateThreadWithContactId:identifier transaction:transaction];
|
||||
[vc presentThread:thread keyboardOnViewAppearing:NO callOnViewAppearing:YES];
|
||||
|
||||
@ -27,7 +27,8 @@ static NSString *const OWS104CreateRecipientIdentitiesMigrationId = @"104";
|
||||
// Overriding runUp instead of runUpWithTransaction in order to implement a blocking migration.
|
||||
- (void)runUp
|
||||
{
|
||||
[[OWSRecipientIdentity dbConnection] readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[[OWSRecipientIdentity dbReadWriteConnection] readWriteWithBlock:^(
|
||||
YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
NSMutableDictionary<NSString *, NSData *> *identityKeys = [NSMutableDictionary new];
|
||||
|
||||
[transaction
|
||||
|
||||
@ -200,10 +200,10 @@
|
||||
NSError *deleteError;
|
||||
if ([fm removeItemAtPath:bloomFilterPath error:&deleteError]) {
|
||||
DDLogInfo(@"Successfully removed bloom filter cache.");
|
||||
[[TSStorageManager sharedManager]
|
||||
.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[transaction removeAllObjectsInCollection:@"TSRecipient"];
|
||||
}];
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[transaction removeAllObjectsInCollection:@"TSRecipient"];
|
||||
}];
|
||||
DDLogInfo(@"Removed all TSRecipient records - will be replaced by SignalRecipients at next address sync.");
|
||||
} else {
|
||||
DDLogError(@"Failed to remove bloom filter cache with error: %@", deleteError.localizedDescription);
|
||||
|
||||
@ -227,7 +227,7 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
|
||||
NSString *threadId = userInfo[Signal_Thread_UserInfo_Key];
|
||||
|
||||
TSThread *thread = [TSThread fetchObjectWithUniqueID:threadId];
|
||||
[[TSStorageManager sharedManager].dbConnection
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
// TODO: I suspect we only want to mark the message in
|
||||
// question as read.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user