Avoid storing images in the database

This commit is contained in:
Cameron Gutman
2018-08-27 01:54:58 -07:00
parent 450960eaaf
commit 90d47004e7
12 changed files with 92 additions and 46 deletions

View File

@@ -263,9 +263,6 @@ static NSMutableSet* hostList;
// on the main thread
[self updateBoxArtCacheForApp:app];
DataManager* dataManager = [[DataManager alloc] init];
[dataManager updateIconForExistingApp: app];
dispatch_async(dispatch_get_main_queue(), ^{
[self.collectionView reloadData];
});
@@ -926,7 +923,13 @@ static NSMutableSet* hostList;
+ (UIImage*) loadBoxArtForCaching:(TemporaryApp*)app {
UIImage* boxArt;
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)app.image, NULL);
NSData* imageData = [NSData dataWithContentsOfFile:[AppAssetManager boxArtPathForApp:app]];
if (imageData == nil) {
// No box art on disk
return nil;
}
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
CGImageRef cgImage = CGImageSourceCreateImageAtIndex(source, 0, nil);
size_t width = CGImageGetWidth(cgImage);
@@ -953,11 +956,12 @@ static NSMutableSet* hostList;
}
- (void) updateBoxArtCacheForApp:(TemporaryApp*)app {
if (app.image == nil) {
[_boxArtCache removeObjectForKey:app];
}
else if ([_boxArtCache objectForKey:app] == nil) {
[_boxArtCache setObject:[MainFrameViewController loadBoxArtForCaching:app] forKey:app];
if ([_boxArtCache objectForKey:app] == nil) {
UIImage* image = [MainFrameViewController loadBoxArtForCaching:app];
if (image != nil) {
// Add the image to our cache if it was present
[_boxArtCache setObject:image forKey:app];
}
}
}