Avoid overzealous assert

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent d458906a64
commit 336aa13520

@ -72,6 +72,7 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
if (!self) { if (!self) {
return self; return self;
} }
DDLogVerbose(@"%@ init attachment with uniqueId: %@", self.logTag, self.uniqueId);
_contentType = contentType; _contentType = contentType;
_byteCount = byteCount; _byteCount = byteCount;

@ -526,14 +526,18 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
void (^successWithDeleteHandler)(void) = ^() { void (^successWithDeleteHandler)(void) = ^() {
successHandler(); successHandler();
DDLogDebug(@"Removing temporary attachment message."); DDLogDebug(@"%@ Removing successful temporary attachment message with attachment ids: %@",
self.logTag,
message.attachmentIds);
[message remove]; [message remove];
}; };
void (^failureWithDeleteHandler)(NSError *error) = ^(NSError *error) { void (^failureWithDeleteHandler)(NSError *error) = ^(NSError *error) {
failureHandler(error); failureHandler(error);
DDLogDebug(@"Removing temporary attachment message."); DDLogDebug(@"%@ Removing failed temporary attachment message with attachment ids: %@",
self.logTag,
message.attachmentIds);
[message remove]; [message remove];
}; };

@ -91,12 +91,9 @@ NS_ASSUME_NONNULL_BEGIN
[self printPaths:orphanDiskFilePaths.allObjects label:@"orphan disk file paths"]; [self printPaths:orphanDiskFilePaths.allObjects label:@"orphan disk file paths"];
[self printPaths:missingAttachmentFilePaths.allObjects label:@"missing attachment file paths"]; [self printPaths:missingAttachmentFilePaths.allObjects label:@"missing attachment file paths"];
NSMutableSet *threadIds = [NSMutableSet new]; __block NSMutableSet *threadIds;
[databaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) { [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
[transaction enumerateKeysInCollection:TSThread.collection threadIds = [[NSMutableSet alloc] initWithArray:[transaction allKeysInCollection:TSThread.collection]];
usingBlock:^(NSString *_Nonnull key, BOOL *_Nonnull stop) {
[threadIds addObject:key];
}];
}]; }];
NSMutableSet<NSString *> *orphanInteractionIds = [NSMutableSet new]; NSMutableSet<NSString *> *orphanInteractionIds = [NSMutableSet new];
@ -156,8 +153,9 @@ NS_ASSUME_NONNULL_BEGIN
for (NSString *attachmentId in orphanAttachmentIds) { for (NSString *attachmentId in orphanAttachmentIds) {
TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction]; TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction];
if (!attachment) { if (!attachment) {
// This could just be a race condition, but it should be very unlikely. // This can happen on launch since we sync contacts/groups, especially if you have a lot of attachments
OWSFail(@"Could not load attachment: %@", attachmentId); // to churn through, it's likely it's been deleted since starting this job.
DDLogWarn(@"%@ Could not load attachment: %@", self.logTag, attachmentId);
continue; continue;
} }
if (![attachment isKindOfClass:[TSAttachmentStream class]]) { if (![attachment isKindOfClass:[TSAttachmentStream class]]) {

Loading…
Cancel
Save