Merge tag '2.18.1.0'

This commit is contained in:
Matthew Chen 2017-11-06 14:28:43 -05:00
commit da7338580c
7 changed files with 43 additions and 19 deletions

View File

@ -38,7 +38,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.18.0</string>
<string>2.18.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@ -55,7 +55,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2.18.0.9</string>
<string>2.18.1.0</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LOGS_EMAIL</key>

View File

@ -1,12 +1,16 @@
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSOutgoingSyncMessage.h"
NS_ASSUME_NONNULL_BEGIN
@class YapDatabaseReadTransaction;
@interface OWSSyncGroupsMessage : OWSOutgoingSyncMessage
- (NSData *)buildPlainTextAttachmentData;
- (NSData *)buildPlainTextAttachmentDataWithTransaction:(YapDatabaseReadTransaction *)transaction;
@end

View File

@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
return syncMessageBuilder;
}
- (NSData *)buildPlainTextAttachmentData
- (NSData *)buildPlainTextAttachmentDataWithTransaction:(YapDatabaseReadTransaction *)transaction
{
// TODO use temp file stream to avoid loading everything into memory at once
// First though, we need to re-engineer our attachment process to accept streams (encrypting with stream,
@ -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];

View File

@ -615,8 +615,8 @@ NS_ASSUME_NONNULL_BEGIN
}];
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeGroups) {
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
DataSource *dataSource =
[DataSourceValue dataSourceWithSyncMessage:[syncGroupsMessage buildPlainTextAttachmentData]];
DataSource *dataSource = [DataSourceValue
dataSourceWithSyncMessage:[syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction]];
[self.messageSender sendTemporaryAttachmentData:dataSource
contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncGroupsMessage

View File

@ -107,9 +107,7 @@ static const CGFloat kAttachmentUploadProgressTheta = 0.001f;
DDLogInfo(@"%@ Uploaded attachment: %p.", self.tag, attachmentStream);
attachmentStream.serverId = serverId;
attachmentStream.isUploaded = YES;
[attachmentStream save];
successHandlerWrapper();
[attachmentStream saveAsyncWithCompletionBlock:successHandlerWrapper];
}
failure:failureHandlerWrapper];

View File

@ -81,10 +81,22 @@
+ (instancetype)fetchObjectWithUniqueID:(NSString *)uniqueID NS_SWIFT_NAME(fetch(uniqueId:));
/**
* Saves the object with a new YapDatabaseConnection
* 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;
/**
* Saves the object with the provided transaction
*

View File

@ -37,6 +37,14 @@
}];
}
- (void)saveAsyncWithCompletionBlock:(void (^_Nullable)(void))completionBlock
{
[[self dbReadWriteConnection] asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self saveWithTransaction:transaction];
}
completionBlock:completionBlock];
}
- (void)touchWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
[transaction touchObjectForKey:self.uniqueId inCollection:[self.class collection]];