Remove sync data files after sync

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent c8a5f50763
commit 2de6927453

@ -24,6 +24,17 @@
success:(successSendingCompletionBlock)successCompletionBlock
failure:(failedSendingCompletionBlock)failedCompletionBlock;
/**
* Delete the local copy of the attachment after sending. Used for sending sync request data, not for user visible
* attachments.
*/
- (void)sendTemporaryAttachment:(NSData *)attachmentData
contentType:(NSString *)contentType
inMessage:(TSOutgoingMessage *)outgoingMessage
thread:(TSThread *)thread
success:(successSendingCompletionBlock)successCompletionBlock
failure:(failedSendingCompletionBlock)failedCompletionBlock;
- (void)retrieveAttachment:(TSAttachmentPointer *)attachment messageId:(NSString *)messageId;
@end

@ -68,6 +68,37 @@ dispatch_queue_t attachmentsQueue() {
}
}
- (void)sendTemporaryAttachment:(NSData *)attachmentData
contentType:(NSString *)contentType
inMessage:(TSOutgoingMessage *)outgoingMessage
thread:(TSThread *)thread
success:(successSendingCompletionBlock)successCompletionBlock
failure:(failedSendingCompletionBlock)failedCompletionBlock
{
void (^successBlockWithDelete)() = ^{
if (successCompletionBlock) {
successCompletionBlock();
}
DDLogDebug(@"Removing temporary attachment message.");
[outgoingMessage remove];
};
void (^failureBlockWithDelete)() = ^{
if (failedCompletionBlock) {
failedCompletionBlock();
}
DDLogDebug(@"Removing temporary attachment message.");
[outgoingMessage remove];
};
[self sendAttachment:attachmentData
contentType:contentType
inMessage:outgoingMessage
thread:thread
success:successBlockWithDelete
failure:failureBlockWithDelete];
}
- (void)sendAttachment:(NSData *)attachmentData
contentType:(NSString *)contentType
inMessage:(TSOutgoingMessage *)outgoingMessage

@ -243,7 +243,7 @@
OWSSyncContactsMessage *syncContactsMessage =
[[OWSSyncContactsMessage alloc] initWithContactsManager:[TextSecureKitEnv sharedEnv].contactsManager];
[self sendAttachment:[syncContactsMessage buildPlainTextAttachmentData]
[self sendTemporaryAttachment:[syncContactsMessage buildPlainTextAttachmentData]
contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncContactsMessage
thread:nil
@ -259,7 +259,7 @@
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
[self sendAttachment:[syncGroupsMessage buildPlainTextAttachmentData]
[self sendTemporaryAttachment:[syncGroupsMessage buildPlainTextAttachmentData]
contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncGroupsMessage
thread:nil

Loading…
Cancel
Save