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

@@ -19,6 +19,22 @@
static const int MAX_REQUEST_COUNT = 4;
+ (NSString*) boxArtPathForApp:(TemporaryApp*)app {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *filePath = [paths objectAtIndex:0];
// Keep app assets separate by host UUID
filePath = [filePath stringByAppendingPathComponent:app.host.uuid];
// Use the app ID as the file name
filePath = [filePath stringByAppendingPathComponent:app.id];
// Add a png extension
filePath = [filePath stringByAppendingPathExtension:@"png"];
return filePath;
}
- (id) initWithCallback:(id<AppAssetCallback>)callback {
self = [super init];
_callback = callback;
@@ -30,7 +46,7 @@ static const int MAX_REQUEST_COUNT = 4;
- (void) retrieveAssetsFromHost:(TemporaryHost*)host {
for (TemporaryApp* app in host.appList) {
if (app.image == nil) {
if (![[NSFileManager defaultManager] fileExistsAtPath:[AppAssetManager boxArtPathForApp:app]]) {
AppAssetRetriever* retriever = [[AppAssetRetriever alloc] init];
retriever.app = app;
retriever.host = host;