Rename AttachmentStream methods.
This commit is contained in:
parent
17f1ba3b9e
commit
498828f93c
|
@ -192,7 +192,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
NSString *filename = self.attachmentStream.sourceFilename;
|
||||
if (!filename) {
|
||||
filename = [[self.attachmentStream filePath] lastPathComponent];
|
||||
filename = [self.attachmentStream.originalFilePath lastPathComponent];
|
||||
}
|
||||
NSString *topText = [[filename stringByDeletingPathExtension] ows_stripped];
|
||||
if (topText.length < 1) {
|
||||
|
|
|
@ -107,7 +107,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
NSString *filename = self.attachmentStream.sourceFilename;
|
||||
if (!filename) {
|
||||
filename = [[self.attachmentStream filePath] lastPathComponent];
|
||||
filename = [[self.attachmentStream originalFilePath] lastPathComponent];
|
||||
}
|
||||
NSString *fileExtension = filename.pathExtension;
|
||||
if (fileExtension.length < 1) {
|
||||
|
@ -149,7 +149,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
NSError *error;
|
||||
unsigned long long fileSize =
|
||||
[[NSFileManager defaultManager] attributesOfItemAtPath:[self.attachmentStream filePath] error:&error].fileSize;
|
||||
[[NSFileManager defaultManager] attributesOfItemAtPath:[self.attachmentStream originalFilePath] error:&error]
|
||||
.fileSize;
|
||||
OWSAssert(!error);
|
||||
NSString *bottomText = [OWSFormat formatFileSize:fileSize];
|
||||
UILabel *bottomLabel = [UILabel new];
|
||||
|
|
|
@ -677,7 +677,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.cellMediaCache setObject:cellMedia forKey:cacheKey];
|
||||
}
|
||||
} else {
|
||||
DDLogError(@"%@ Failed to load cell media: %@", [self logTag], [self.attachmentStream mediaURL]);
|
||||
DDLogError(@"%@ Failed to load cell media: %@", [self logTag], [self.attachmentStream originalMediaURL]);
|
||||
self.viewItem.didCellMediaFailToLoad = YES;
|
||||
[self showAttachmentErrorViewWithMediaView:mediaView];
|
||||
}
|
||||
|
@ -851,7 +851,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// TODO: Don't use full size images in the message cells.
|
||||
const NSUInteger kMaxCachableSize = 1024 * 1024;
|
||||
BOOL shouldSkipCache =
|
||||
[OWSFileSystem fileSizeOfPath:strongSelf.attachmentStream.filePath].unsignedIntegerValue < kMaxCachableSize;
|
||||
[OWSFileSystem fileSizeOfPath:strongSelf.attachmentStream.originalFilePath].unsignedIntegerValue
|
||||
< kMaxCachableSize;
|
||||
stillImageView.image = [strongSelf tryToLoadCellMedia:^{
|
||||
OWSCAssert([strongSelf.attachmentStream isImage]);
|
||||
return strongSelf.attachmentStream.image;
|
||||
|
@ -897,7 +898,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
animatedImageView.image = [strongSelf tryToLoadCellMedia:^{
|
||||
OWSCAssert([strongSelf.attachmentStream isAnimated]);
|
||||
|
||||
NSString *_Nullable filePath = [strongSelf.attachmentStream filePath];
|
||||
NSString *_Nullable filePath = [strongSelf.attachmentStream originalFilePath];
|
||||
YYImage *_Nullable animatedImage = nil;
|
||||
if (strongSelf.attachmentStream.isValidImage && filePath) {
|
||||
animatedImage = [YYImage imageWithContentsOfFile:filePath];
|
||||
|
|
|
@ -2219,8 +2219,8 @@ typedef enum : NSUInteger {
|
|||
OWSAssert(attachmentStream);
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
if (![fileManager fileExistsAtPath:[attachmentStream.mediaURL path]]) {
|
||||
OWSFail(@"%@ Missing video file: %@", self.logTag, attachmentStream.mediaURL);
|
||||
if (![fileManager fileExistsAtPath:attachmentStream.originalFilePath]) {
|
||||
OWSFail(@"%@ Missing video file: %@", self.logTag, attachmentStream.originalFilePath);
|
||||
}
|
||||
|
||||
[self dismissKeyBoard];
|
||||
|
@ -2235,7 +2235,8 @@ typedef enum : NSUInteger {
|
|||
[self.audioAttachmentPlayer stop];
|
||||
self.audioAttachmentPlayer = nil;
|
||||
}
|
||||
self.audioAttachmentPlayer = [[OWSAudioPlayer alloc] initWithMediaUrl:attachmentStream.mediaURL delegate:viewItem];
|
||||
self.audioAttachmentPlayer =
|
||||
[[OWSAudioPlayer alloc] initWithMediaUrl:attachmentStream.originalMediaURL delegate:viewItem];
|
||||
// Associate the player with this media adapter.
|
||||
self.audioAttachmentPlayer.owner = viewItem;
|
||||
[self.audioAttachmentPlayer playWithPlaybackAudioCategory];
|
||||
|
|
|
@ -382,7 +382,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
|
||||
return [self displayableTextForCacheKey:displayableTextCacheKey
|
||||
textBlock:^{
|
||||
NSData *textData = [NSData dataWithContentsOfURL:attachmentStream.mediaURL];
|
||||
NSData *textData =
|
||||
[NSData dataWithContentsOfURL:attachmentStream.originalMediaURL];
|
||||
NSString *text =
|
||||
[[NSString alloc] initWithData:textData encoding:NSUTF8StringEncoding];
|
||||
return text;
|
||||
|
@ -733,7 +734,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
OWSFail(@"%@ Unknown MIME type: %@", self.logTag, self.attachmentStream.contentType);
|
||||
utiType = (NSString *)kUTTypeGIF;
|
||||
}
|
||||
NSData *data = [NSData dataWithContentsOfURL:[self.attachmentStream mediaURL]];
|
||||
NSData *data = [NSData dataWithContentsOfURL:[self.attachmentStream originalMediaURL]];
|
||||
if (!data) {
|
||||
OWSFail(@"%@ Could not load attachment data", self.logTag);
|
||||
return;
|
||||
|
@ -814,7 +815,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
case OWSMessageCellType_Audio:
|
||||
return NO;
|
||||
case OWSMessageCellType_Video:
|
||||
return UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.attachmentStream.mediaURL.path);
|
||||
return UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.attachmentStream.originalFilePath);
|
||||
case OWSMessageCellType_GenericAttachment:
|
||||
return NO;
|
||||
case OWSMessageCellType_DownloadingAttachment: {
|
||||
|
@ -834,7 +835,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
break;
|
||||
case OWSMessageCellType_StillImage:
|
||||
case OWSMessageCellType_AnimatedImage: {
|
||||
NSData *data = [NSData dataWithContentsOfURL:[self.attachmentStream mediaURL]];
|
||||
NSData *data = [NSData dataWithContentsOfURL:[self.attachmentStream originalMediaURL]];
|
||||
if (!data) {
|
||||
OWSFail(@"%@ Could not load image data", self.logTag);
|
||||
return;
|
||||
|
@ -853,8 +854,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
OWSFail(@"%@ Cannot save media data.", self.logTag);
|
||||
break;
|
||||
case OWSMessageCellType_Video:
|
||||
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.attachmentStream.mediaURL.path)) {
|
||||
UISaveVideoAtPathToSavedPhotosAlbum(self.attachmentStream.mediaURL.path, self, nil, nil);
|
||||
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.attachmentStream.originalFilePath)) {
|
||||
UISaveVideoAtPathToSavedPhotosAlbum(self.attachmentStream.originalFilePath, self, nil, nil);
|
||||
} else {
|
||||
OWSFail(@"%@ Could not save incompatible video data.", self.logTag);
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (NSURL *_Nullable)attachmentUrl
|
||||
{
|
||||
return self.attachmentStream.mediaURL;
|
||||
return self.attachmentStream.originalMediaURL;
|
||||
}
|
||||
|
||||
- (NSData *)fileData
|
||||
|
|
|
@ -651,7 +651,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
|
|||
func didTapAudioViewItem(_ viewItem: ConversationViewItem, attachmentStream: TSAttachmentStream) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
guard let mediaURL = attachmentStream.mediaURL() else {
|
||||
guard let mediaURL = attachmentStream.originalMediaURL() else {
|
||||
owsFail("\(logTag) in \(#function) mediaURL was unexpectedly nil for attachment: \(attachmentStream)")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -546,7 +546,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
OWSAssert(backupIO);
|
||||
OWSAssert(completion);
|
||||
|
||||
NSString *_Nullable attachmentFilePath = [attachment filePath];
|
||||
NSString *_Nullable attachmentFilePath = [attachment originalFilePath];
|
||||
if (attachmentFilePath.length < 1) {
|
||||
DDLogError(@"%@ Attachment has invalid file path.", self.logTag);
|
||||
return completion(NO);
|
||||
|
@ -617,7 +617,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}
|
||||
}
|
||||
|
||||
NSString *_Nullable attachmentFilePath = [attachment filePath];
|
||||
NSString *_Nullable attachmentFilePath = [attachment originalFilePath];
|
||||
if (attachmentFilePath.length < 1) {
|
||||
DDLogError(@"%@ Attachment has invalid file path.", self.logTag);
|
||||
return completion(NO);
|
||||
|
|
|
@ -539,7 +539,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return NO;
|
||||
}
|
||||
TSAttachmentStream *attachmentStream = object;
|
||||
NSString *_Nullable filePath = attachmentStream.filePath;
|
||||
NSString *_Nullable filePath = attachmentStream.originalFilePath;
|
||||
if (!filePath) {
|
||||
DDLogError(@"%@ attachment is missing file.", self.logTag);
|
||||
return NO;
|
||||
|
|
|
@ -316,7 +316,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
|
|||
|
||||
TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment;
|
||||
attachmentStreamCount++;
|
||||
NSString *_Nullable filePath = [attachmentStream filePath];
|
||||
NSString *_Nullable filePath = [attachmentStream originalFilePath];
|
||||
if (filePath) {
|
||||
[allAttachmentFilePaths addObject:filePath];
|
||||
} else {
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
TSAttachment *_Nullable attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId];
|
||||
XCTAssertTrue([attachment isKindOfClass:[TSAttachmentStream class]]);
|
||||
TSAttachmentStream *_Nullable attachmentStream = (TSAttachmentStream *)attachment;
|
||||
NSString *_Nullable filePath = attachmentStream.filePath;
|
||||
NSString *_Nullable filePath = attachmentStream.originalFilePath;
|
||||
XCTAssertNotNil(filePath);
|
||||
|
||||
XCTAssertNotNil([TSMessage fetchObjectWithUniqueID:viewItem.interaction.uniqueId]);
|
||||
|
@ -148,7 +148,7 @@
|
|||
TSAttachment *_Nullable attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId];
|
||||
XCTAssertTrue([attachment isKindOfClass:[TSAttachmentStream class]]);
|
||||
TSAttachmentStream *_Nullable attachmentStream = (TSAttachmentStream *)attachment;
|
||||
NSString *_Nullable filePath = attachmentStream.filePath;
|
||||
NSString *_Nullable filePath = attachmentStream.originalFilePath;
|
||||
XCTAssertNotNil(filePath);
|
||||
|
||||
XCTAssertNotNil([TSMessage fetchObjectWithUniqueID:viewItem.interaction.uniqueId]);
|
||||
|
@ -170,7 +170,7 @@
|
|||
TSAttachment *_Nullable attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId];
|
||||
XCTAssertTrue([attachment isKindOfClass:[TSAttachmentStream class]]);
|
||||
TSAttachmentStream *_Nullable attachmentStream = (TSAttachmentStream *)attachment;
|
||||
NSString *_Nullable filePath = attachmentStream.filePath;
|
||||
NSString *_Nullable filePath = attachmentStream.originalFilePath;
|
||||
XCTAssertNotNil(filePath);
|
||||
|
||||
XCTAssertNotNil([TSMessage fetchObjectWithUniqueID:viewItem.interaction.uniqueId]);
|
||||
|
@ -192,7 +192,7 @@
|
|||
TSAttachment *_Nullable attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId];
|
||||
XCTAssertTrue([attachment isKindOfClass:[TSAttachmentStream class]]);
|
||||
TSAttachmentStream *_Nullable attachmentStream = (TSAttachmentStream *)attachment;
|
||||
NSString *_Nullable filePath = attachmentStream.filePath;
|
||||
NSString *_Nullable filePath = attachmentStream.originalFilePath;
|
||||
XCTAssertNotNil(filePath);
|
||||
|
||||
XCTAssertNotNil([TSMessage fetchObjectWithUniqueID:viewItem.interaction.uniqueId]);
|
||||
|
|
|
@ -179,7 +179,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
hasText = YES;
|
||||
quotedText = @"";
|
||||
|
||||
NSData *_Nullable oversizeTextData = [NSData dataWithContentsOfFile:attachmentStream.filePath];
|
||||
NSData *_Nullable oversizeTextData = [NSData dataWithContentsOfFile:attachmentStream.originalFilePath];
|
||||
if (oversizeTextData) {
|
||||
// We don't need to include the entire text body of the message, just
|
||||
// enough to render a snippet. kOversizeTextMessageSizeThreshold is our
|
||||
|
|
|
@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
{
|
||||
OWSAssert(stream);
|
||||
|
||||
[self showShareUIForURL:stream.mediaURL];
|
||||
[self showShareUIForURL:stream.originalMediaURL];
|
||||
}
|
||||
|
||||
+ (void)showShareUIForURL:(NSURL *)url
|
||||
|
|
|
@ -47,11 +47,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (BOOL)isImage;
|
||||
- (BOOL)isVideo;
|
||||
- (BOOL)isAudio;
|
||||
- (nullable NSURL *)mediaURL;
|
||||
|
||||
+ (BOOL)hasThumbnailForMimeType:(NSString *)contentType;
|
||||
|
||||
- (nullable NSString *)filePath;
|
||||
- (nullable NSString *)originalFilePath;
|
||||
- (nullable NSURL *)originalMediaURL;
|
||||
|
||||
- (nullable NSString *)thumbnailPath;
|
||||
|
||||
- (nullable NSData *)readDataFromFileWithError:(NSError **)error;
|
||||
|
|
|
@ -156,7 +156,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
}
|
||||
|
||||
self.localRelativeFilePath = localRelativeFilePath;
|
||||
OWSAssert(self.filePath);
|
||||
OWSAssert(self.originalFilePath);
|
||||
}
|
||||
|
||||
#pragma mark - File Management
|
||||
|
@ -164,7 +164,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
- (nullable NSData *)readDataFromFileWithError:(NSError **)error
|
||||
{
|
||||
*error = nil;
|
||||
NSString *_Nullable filePath = self.filePath;
|
||||
NSString *_Nullable filePath = self.originalFilePath;
|
||||
if (!filePath) {
|
||||
OWSFail(@"%@ Missing path for attachment.", self.logTag);
|
||||
return nil;
|
||||
|
@ -177,7 +177,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
OWSAssert(data);
|
||||
|
||||
*error = nil;
|
||||
NSString *_Nullable filePath = self.filePath;
|
||||
NSString *_Nullable filePath = self.originalFilePath;
|
||||
if (!filePath) {
|
||||
OWSFail(@"%@ Missing path for attachment.", self.logTag);
|
||||
return NO;
|
||||
|
@ -190,7 +190,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
{
|
||||
OWSAssert(dataSource);
|
||||
|
||||
NSString *_Nullable filePath = self.filePath;
|
||||
NSString *_Nullable filePath = self.originalFilePath;
|
||||
if (!filePath) {
|
||||
OWSFail(@"%@ Missing path for attachment.", self.logTag);
|
||||
return NO;
|
||||
|
@ -229,7 +229,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
return attachmentsFolder;
|
||||
}
|
||||
|
||||
- (nullable NSString *)filePath
|
||||
- (nullable NSString *)originalFilePath
|
||||
{
|
||||
if (!self.localRelativeFilePath) {
|
||||
OWSFail(@"%@ Attachment missing local file path.", self.logTag);
|
||||
|
@ -241,7 +241,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
|
||||
- (nullable NSString *)thumbnailPath
|
||||
{
|
||||
NSString *filePath = self.filePath;
|
||||
NSString *filePath = self.originalFilePath;
|
||||
if (!filePath) {
|
||||
OWSFail(@"%@ Attachment missing local file path.", self.logTag);
|
||||
return nil;
|
||||
|
@ -258,9 +258,9 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
return [[containingDir stringByAppendingPathComponent:newFilename] stringByAppendingPathExtension:@"jpg"];
|
||||
}
|
||||
|
||||
- (nullable NSURL *)mediaURL
|
||||
- (nullable NSURL *)originalMediaURL
|
||||
{
|
||||
NSString *_Nullable filePath = self.filePath;
|
||||
NSString *_Nullable filePath = self.originalFilePath;
|
||||
if (!filePath) {
|
||||
OWSFail(@"%@ Missing path for attachment.", self.logTag);
|
||||
return nil;
|
||||
|
@ -281,7 +281,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
}
|
||||
}
|
||||
|
||||
NSString *_Nullable filePath = self.filePath;
|
||||
NSString *_Nullable filePath = self.originalFilePath;
|
||||
if (!filePath) {
|
||||
OWSFail(@"%@ Missing path for attachment.", self.logTag);
|
||||
return;
|
||||
|
@ -321,14 +321,14 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
{
|
||||
OWSAssert(self.isImage || self.isAnimated);
|
||||
|
||||
return [NSData ows_isValidImageAtPath:self.filePath mimeType:self.contentType];
|
||||
return [NSData ows_isValidImageAtPath:self.originalFilePath mimeType:self.contentType];
|
||||
}
|
||||
|
||||
- (BOOL)isValidVideo
|
||||
{
|
||||
OWSAssert(self.isVideo);
|
||||
|
||||
return [NSData ows_isValidVideoAtURL:self.mediaURL];
|
||||
return [NSData ows_isValidVideoAtURL:self.originalMediaURL];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
@ -338,14 +338,14 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
if ([self isVideo]) {
|
||||
return [self videoStillImage];
|
||||
} else if ([self isImage] || [self isAnimated]) {
|
||||
NSURL *_Nullable mediaUrl = [self mediaURL];
|
||||
NSURL *_Nullable mediaUrl = self.originalMediaURL;
|
||||
if (!mediaUrl) {
|
||||
return nil;
|
||||
}
|
||||
if (![self isValidImage]) {
|
||||
return nil;
|
||||
}
|
||||
return [[UIImage alloc] initWithContentsOfFile:self.filePath];
|
||||
return [[UIImage alloc] initWithContentsOfFile:self.originalFilePath];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
|
@ -362,12 +362,12 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
return nil;
|
||||
}
|
||||
|
||||
if (![NSData ows_isValidImageAtPath:self.filePath mimeType:self.contentType]) {
|
||||
if (![NSData ows_isValidImageAtPath:self.originalFilePath mimeType:self.contentType]) {
|
||||
OWSFail(@"%@ skipping invalid image", self.logTag);
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [NSData dataWithContentsOfFile:self.filePath];
|
||||
return [NSData dataWithContentsOfFile:self.originalFilePath];
|
||||
}
|
||||
|
||||
+ (BOOL)hasThumbnailForMimeType:(NSString *)contentType
|
||||
|
@ -425,8 +425,8 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
return;
|
||||
}
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:self.mediaURL.path]) {
|
||||
DDLogError(@"%@ while generating thumbnail, source file doesn't exist: %@", self.logTag, self.mediaURL);
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:self.originalMediaURL.path]) {
|
||||
DDLogError(@"%@ while generating thumbnail, source file doesn't exist: %@", self.logTag, self.originalMediaURL);
|
||||
// If we're not lazy-restoring this message, the attachment should exist on disk.
|
||||
OWSAssert(self.lazyRestoreFragmentId);
|
||||
return;
|
||||
|
@ -438,11 +438,12 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
UIImage *_Nullable result;
|
||||
if (self.isImage || self.isAnimated) {
|
||||
if (![self isValidImage]) {
|
||||
DDLogWarn(@"%@ skipping thumbnail generation for invalid image at path: %@", self.logTag, self.filePath);
|
||||
DDLogWarn(
|
||||
@"%@ skipping thumbnail generation for invalid image at path: %@", self.logTag, self.originalFilePath);
|
||||
return;
|
||||
}
|
||||
|
||||
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)self.mediaURL, NULL);
|
||||
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)self.originalMediaURL, NULL);
|
||||
OWSAssert(imageSource != NULL);
|
||||
NSDictionary *imageOptions = @{
|
||||
(NSString const *)kCGImageSourceCreateThumbnailFromImageIfAbsent : (NSNumber const *)kCFBooleanTrue,
|
||||
|
@ -458,7 +459,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);
|
||||
DDLogWarn(@"%@ skipping thumbnail for invalid video at path: %@", self.logTag, self.originalFilePath);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -496,7 +497,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
maxSize.width = MIN(maxSize.width, kMaxVideoStillSize);
|
||||
maxSize.height = MIN(maxSize.height, kMaxVideoStillSize);
|
||||
|
||||
NSURL *_Nullable mediaUrl = [self mediaURL];
|
||||
NSURL *_Nullable mediaUrl = self.originalMediaURL;
|
||||
if (!mediaUrl) {
|
||||
return nil;
|
||||
}
|
||||
|
@ -509,7 +510,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);
|
||||
DDLogError(@"Could not generate video still: %@", self.originalFilePath.pathExtension);
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -546,7 +547,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
}
|
||||
return [self videoStillImage].size;
|
||||
} else if ([self isImage] || [self isAnimated]) {
|
||||
NSURL *_Nullable mediaUrl = [self mediaURL];
|
||||
NSURL *_Nullable mediaUrl = self.originalMediaURL;
|
||||
if (!mediaUrl) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
@ -656,7 +657,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
OWSAssert([self isAudio]);
|
||||
|
||||
NSError *error;
|
||||
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:self.mediaURL error:&error];
|
||||
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:self.originalMediaURL error:&error];
|
||||
if (error && [error.domain isEqualToString:NSOSStatusErrorDomain]
|
||||
&& (error.code == kAudioFileInvalidFileError || error.code == kAudioFileStreamError_InvalidFile)) {
|
||||
// Ignore "invalid audio file" errors.
|
||||
|
@ -665,7 +666,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024;
|
|||
if (!error) {
|
||||
return (CGFloat)[audioPlayer duration];
|
||||
} else {
|
||||
DDLogError(@"Could not find audio duration: %@", self.mediaURL);
|
||||
DDLogError(@"Could not find audio duration: %@", self.originalMediaURL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
[attachment isKindOfClass:TSAttachmentStream.class]) {
|
||||
TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment;
|
||||
|
||||
NSData *_Nullable data = [NSData dataWithContentsOfFile:attachmentStream.filePath];
|
||||
NSData *_Nullable data = [NSData dataWithContentsOfFile:attachmentStream.originalFilePath];
|
||||
if (data) {
|
||||
NSString *_Nullable text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
if (text) {
|
||||
|
@ -263,7 +263,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
// Handle oversize text attachments.
|
||||
if ([attachment isKindOfClass:[TSAttachmentStream class]]) {
|
||||
TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment;
|
||||
NSData *_Nullable data = [NSData dataWithContentsOfFile:attachmentStream.filePath];
|
||||
NSData *_Nullable data = [NSData dataWithContentsOfFile:attachmentStream.originalFilePath];
|
||||
if (data) {
|
||||
NSString *_Nullable text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
if (text) {
|
||||
|
|
Loading…
Reference in New Issue