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

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

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

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

Loading…
Cancel
Save