Merge branch 'charlesmchen/hotfixLoggingAndFails'

pull/1/head
Matthew Chen 7 years ago
commit 6f6b1d0aae

@ -482,7 +482,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
[self.attachmentStream isVideo]) {
if ([self.attachmentStream isAnimated]) {
if (![self.attachmentStream isValidImage]) {
DDLogWarn(@"Treating invalid image as generic attachment.");
OWSLogWarn(@"Treating invalid image as generic attachment.");
self.messageCellType = OWSMessageCellType_GenericAttachment;
return;
}
@ -490,7 +490,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
self.messageCellType = OWSMessageCellType_AnimatedImage;
} else if ([self.attachmentStream isImage]) {
if (![self.attachmentStream isValidImage]) {
DDLogWarn(@"Treating invalid image as generic attachment.");
OWSLogWarn(@"Treating invalid image as generic attachment.");
self.messageCellType = OWSMessageCellType_GenericAttachment;
return;
}
@ -498,7 +498,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
self.messageCellType = OWSMessageCellType_StillImage;
} else if ([self.attachmentStream isVideo]) {
if (![self.attachmentStream isValidVideo]) {
DDLogWarn(@"Treating invalid video as generic attachment.");
OWSLogWarn(@"Treating invalid video as generic attachment.");
self.messageCellType = OWSMessageCellType_GenericAttachment;
return;
}

@ -197,7 +197,7 @@ class GifPickerCell: UICollectionViewCell {
return
}
guard NSData.ows_isValidImage(atPath: asset.filePath, mimeType: OWSMimeTypeImageGif) else {
owsFail("\(logTag) invalid asset.")
owsFailDebug("invalid asset.")
clearViewState()
return
}

@ -363,7 +363,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
}
if (![NSData ows_isValidImageAtPath:self.filePath mimeType:self.contentType]) {
OWSFail(@"%@ skipping invalid image", self.logTag);
OWSFailDebug(@"%@ skipping invalid image", self.logTag);
return nil;
}
@ -458,7 +458,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
} else if (self.isVideo) {
if (![self isValidVideo]) {
DDLogWarn(@"%@ skipping thumbnail for invalid video at path: %@", self.logTag, self.filePath);
OWSLogWarn(@"Skipping thumbnail for invalid video at path: %@", self.filePath);
return;
}
@ -507,7 +507,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
CMTime time = CMTimeMake(1, 60);
CGImageRef imgRef = [generator copyCGImageAtTime:time actualTime:NULL error:&err];
if (imgRef == NULL) {
DDLogError(@"Could not generate video still: %@", self.filePath.pathExtension);
OWSLogError(@"Could not generate video still: %@", self.filePath.pathExtension);
return nil;
}

@ -49,7 +49,7 @@ typedef NS_ENUM(NSInteger, ImageFormat) {
}
if (![self ows_hasValidImageDimensionsAtPath:filePath]) {
DDLogError(@"%@ image had invalid dimensions.", self.logTag);
OWSLogError(@"image had invalid dimensions.");
return NO;
}
@ -96,14 +96,14 @@ typedef NS_ENUM(NSInteger, ImageFormat) {
NSNumber *widthNumber = imageProperties[(__bridge NSString *)kCGImagePropertyPixelWidth];
if (!widthNumber) {
DDLogError(@"widthNumber was unexpectedly nil");
OWSLogError(@"widthNumber was unexpectedly nil");
return NO;
}
CGFloat width = widthNumber.floatValue;
NSNumber *heightNumber = imageProperties[(__bridge NSString *)kCGImagePropertyPixelHeight];
if (!heightNumber) {
DDLogError(@"heightNumber was unexpectedly nil");
OWSLogError(@"heightNumber was unexpectedly nil");
return NO;
}
CGFloat height = heightNumber.floatValue;
@ -112,7 +112,7 @@ typedef NS_ENUM(NSInteger, ImageFormat) {
* key is a CFNumberRef. */
NSNumber *depthNumber = imageProperties[(__bridge NSString *)kCGImagePropertyDepth];
if (!depthNumber) {
DDLogError(@"depthNumber was unexpectedly nil");
OWSLogError(@"depthNumber was unexpectedly nil");
return NO;
}
NSUInteger depthBits = depthNumber.unsignedIntegerValue;
@ -122,12 +122,12 @@ typedef NS_ENUM(NSInteger, ImageFormat) {
* The value of this key is CFStringRef. */
NSString *colorModel = imageProperties[(__bridge NSString *)kCGImagePropertyColorModel];
if (!colorModel) {
DDLogError(@"colorModel was unexpectedly nil");
OWSLogError(@"colorModel was unexpectedly nil");
return NO;
}
if (![colorModel isEqualToString:(__bridge NSString *)kCGImagePropertyColorModelRGB]
&& ![colorModel isEqualToString:(__bridge NSString *)kCGImagePropertyColorModelGray]) {
DDLogError(@"Invalid colorModel: %@", colorModel);
OWSLogError(@"Invalid colorModel: %@", colorModel);
return NO;
}
@ -140,7 +140,7 @@ typedef NS_ENUM(NSInteger, ImageFormat) {
CGFloat kMaxBytes = kMaxDimension * kMaxDimension * kExpectedBytePerPixel;
CGFloat actualBytes = width * height * bytesPerPixel;
if (actualBytes > kMaxBytes) {
DDLogWarn(@"invalid dimensions width: %f, height %f, bytesPerPixel: %f", width, height, bytesPerPixel);
OWSLogWarn(@"invalid dimensions width: %f, height %f, bytesPerPixel: %f", width, height, bytesPerPixel);
return NO;
}
@ -273,12 +273,12 @@ typedef NS_ENUM(NSInteger, ImageFormat) {
maxSize.height = MAX(maxSize.height, trackSize.height);
}
if (maxSize.width < 1.f || maxSize.height < 1.f) {
DDLogError(@"Invalid video size: %@", NSStringFromCGSize(maxSize));
OWSLogError(@"Invalid video size: %@", NSStringFromCGSize(maxSize));
return NO;
}
const CGFloat kMaxSize = 3 * 1024.f;
if (maxSize.width > kMaxSize || maxSize.height > kMaxSize) {
DDLogError(@"Invalid video dimensions: %@", NSStringFromCGSize(maxSize));
OWSLogError(@"Invalid video dimensions: %@", NSStringFromCGSize(maxSize));
return NO;
}
return YES;

Loading…
Cancel
Save