mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Add asserts around attachment crash.
This commit is contained in:
parent
4a84a19d00
commit
1260e7459d
2 changed files with 21 additions and 3 deletions
|
@ -8,6 +8,7 @@
|
|||
#import <SignalServiceKit/MimeTypeUtil.h>
|
||||
#import <SignalServiceKit/SignalServiceKit-Swift.h>
|
||||
#import <YapDatabase/YapDatabase.h>
|
||||
#import <YapDatabase/YapDatabaseTransaction.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -209,6 +210,22 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}];
|
||||
}
|
||||
|
||||
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (self.uniqueId.length > 0) {
|
||||
id _Nullable oldObject = [transaction objectForKey:self.uniqueId inCollection:TSAttachment.collection];
|
||||
if ([oldObject isKindOfClass:[TSAttachmentStream class]]) {
|
||||
OWSFailDebug(@"We should never overwrite a TSAttachmentStream with a TSAttachmentPointer.");
|
||||
}
|
||||
} else {
|
||||
OWSFailDebug(@"Missing uniqueId.");
|
||||
}
|
||||
#endif
|
||||
|
||||
[super saveWithTransaction:transaction];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -524,10 +524,11 @@ typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail);
|
|||
self.cachedImageHeight = @(imageSize.height);
|
||||
|
||||
[self.dbReadWriteConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
|
||||
NSString *collection = [[self class] collection];
|
||||
NSString *collection = [TSAttachmentStream collection];
|
||||
TSAttachmentStream *latestInstance = [transaction objectForKey:self.uniqueId inCollection:collection];
|
||||
if (latestInstance) {
|
||||
if (![latestInstance isKindOfClass:[TSAttachmentStream class]]) {
|
||||
OWSFailDebug(@"Attachment has unexpected type: %@", latestInstance.class);
|
||||
} else if (latestInstance) {
|
||||
latestInstance.cachedImageWidth = @(imageSize.width);
|
||||
latestInstance.cachedImageHeight = @(imageSize.height);
|
||||
[latestInstance saveWithTransaction:transaction];
|
||||
|
|
Loading…
Reference in a new issue