Commit 4d58a0c8 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Thumbnailer Queue: improved sanity checks

parent 2c93d52b
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#import "MLFile.h" #import "MLFile.h"
#import "MLCrashPreventer.h" #import "MLCrashPreventer.h"
#import "MLMediaLibrary.h" #import "MLMediaLibrary.h"
#import "MLFileParserQueue.h"
@interface ThumbnailOperation : NSOperation <VLCMediaThumbnailerDelegate> @interface ThumbnailOperation : NSOperation <VLCMediaThumbnailerDelegate>
{ {
...@@ -90,8 +91,13 @@ ...@@ -90,8 +91,13 @@
- (void)mediaThumbnailer:(VLCMediaThumbnailer *)mediaThumbnailer didFinishThumbnail:(CGImageRef)thumbnail - (void)mediaThumbnailer:(VLCMediaThumbnailer *)mediaThumbnailer didFinishThumbnail:(CGImageRef)thumbnail
{ {
mediaThumbnailer.delegate = nil; mediaThumbnailer.delegate = nil;
APLog(@"Finished thumbnail for %@", self.file.title); MLFile *file = self.file;
self.file.computedThumbnail = [UIImage imageWithCGImage:thumbnail]; APLog(@"Finished thumbnail for %@", file.title);
if (thumbnail) {
UIImage *thumbnailImage = [UIImage imageWithCGImage:thumbnail];
if (thumbnailImage)
file.computedThumbnail = [UIImage imageWithCGImage:thumbnail];
}
[self endThumbnailing]; [self endThumbnailing];
} }
...@@ -150,11 +156,22 @@ static inline NSString *hashFromFile(MLFile *file) ...@@ -150,11 +156,22 @@ static inline NSString *hashFromFile(MLFile *file)
return; return;
} }
if ([file isAlbumTrack]) { if (file.albumTrack) {
file.type = kMLFileTypeAudio; APLog(@"'%@' is part of a music album, ignoring", file.title);
return;
}
if ([file isKindOfType:kMLFileTypeAudio]) {
APLog(@"'%@' is an audio file, ignoring", file.title); APLog(@"'%@' is an audio file, ignoring", file.title);
return; return;
} }
if (file.hasFetchedInfo.boolValue != YES) {
APLog(@"'%@' still awaits parsing, ignoring", file.title);
[[MLFileParserQueue sharedFileParserQueue] addFile:file];
return;
}
ThumbnailOperation *op = [[ThumbnailOperation alloc] initWithFile:file andVLCLibrary:_internalLibrary]; ThumbnailOperation *op = [[ThumbnailOperation alloc] initWithFile:file andVLCLibrary:_internalLibrary];
[_fileDescriptionToOperation setValue:op forKey:hashFromFile(file)]; [_fileDescriptionToOperation setValue:op forKey:hashFromFile(file)];
[self.queue addOperation:op]; [self.queue addOperation:op];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment