From e82a3f3ddf4def4d34f8db344bbdb6b6b1c01d50 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 6 Nov 2017 11:52:28 -0500 Subject: [PATCH] respond to CR // FREEBIE --- .../DeviceSyncing/OWSSyncGroupsMessage.m | 18 ++++++++++-------- .../src/Storage/TSYapDatabaseObject.h | 13 ++++++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsMessage.m b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsMessage.m index 9e5a719c0..651a7edb7 100644 --- a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsMessage.m +++ b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsMessage.m @@ -49,14 +49,16 @@ NS_ASSUME_NONNULL_BEGIN [dataOutputStream open]; OWSGroupsOutputStream *groupsOutputStream = [OWSGroupsOutputStream streamWithOutputStream:dataOutputStream]; - [TSGroupThread enumerateCollectionObjectsUsingBlock:^(id obj, BOOL *stop) { - if (![obj isKindOfClass:[TSGroupThread class]]) { - DDLogVerbose(@"Ignoring non group thread in thread collection: %@", obj); - return; - } - TSGroupModel *group = ((TSGroupThread *)obj).groupModel; - [groupsOutputStream writeGroup:group]; - }]; + [TSGroupThread + enumerateCollectionObjectsWithTransaction:transaction + usingBlock:^(id obj, BOOL *stop) { + if (![obj isKindOfClass:[TSGroupThread class]]) { + DDLogVerbose(@"Ignoring non group thread in thread collection: %@", obj); + return; + } + TSGroupModel *group = ((TSGroupThread *)obj).groupModel; + [groupsOutputStream writeGroup:group]; + }]; [groupsOutputStream flush]; [dataOutputStream close]; diff --git a/SignalServiceKit/src/Storage/TSYapDatabaseObject.h b/SignalServiceKit/src/Storage/TSYapDatabaseObject.h index f77f36b29..cb68f9496 100644 --- a/SignalServiceKit/src/Storage/TSYapDatabaseObject.h +++ b/SignalServiceKit/src/Storage/TSYapDatabaseObject.h @@ -81,9 +81,20 @@ + (instancetype)fetchObjectWithUniqueID:(NSString *)uniqueID NS_SWIFT_NAME(fetch(uniqueId:)); /** - * Saves the object with shared readWrite connection. + * Saves the object with the shared readWrite connection. + * + * This method will block if another readWrite transaction is open. */ - (void)save; + +/** + * Saves the object with the shared readWrite connection - does not block. + * + * Be mindful that this method may clobber other changes persisted + * while waiting to open the readWrite transaction. + * + * @param completionBlock is called on the main thread + */ - (void)saveAsyncWithCompletionBlock:(void (^_Nullable)(void))completionBlock; /**