diff --git a/MacPass/MPTemporaryFileStorage.m b/MacPass/MPTemporaryFileStorage.m index fb890b2e..18c13bf5 100644 --- a/MacPass/MPTemporaryFileStorage.m +++ b/MacPass/MPTemporaryFileStorage.m @@ -41,7 +41,6 @@ self = [super init]; if(self) { _binary = binary; - _loadScheduled = NO; [MPTemporaryFileStorageCenter.defaultCenter registerStorage:self]; } return self; @@ -64,17 +63,8 @@ #pragma mark QLPreviewPanelDataSource - (id)previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)index { - if(!self.temporaryFileURL && !self.loadScheduled) { - self.loadScheduled = YES; - dispatch_queue_t defaultQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - dispatch_async(defaultQueue, ^{ - BOOL success = [self _saveBinary:self.binary]; - if(success){ - dispatch_async(dispatch_get_main_queue(), ^{ - [panel refreshCurrentPreviewItem]; - }); - } - }); + if(!self.temporaryFileURL) { + [self _saveBinary:self.binary]; } return self; } @@ -98,7 +88,7 @@ #pragma mark Private - (BOOL)_saveBinary:(KPKBinary *)binary { - if(!binary || !binary.data || !binary.name || [binary.name length] == 0) { + if(!binary || !binary.data || !binary.name || binary.name.length == 0) { return NO; } NSString *fileName = [NSString stringWithFormat:@"%@_%@", NSProcessInfo.processInfo.globallyUniqueString, binary.name]; @@ -142,7 +132,9 @@ } + (void)_runCleanupForPath:(NSString *)path { - NSTask *task = [[NSTask alloc] init]; + NSTask *task = [[NSTask alloc] init]; + + // FIXME: Remove when moving to 10.12 as deploy target NSURL *srmURL = [NSURL fileURLWithPath:@"/usr/bin/srm"]; NSURL *rmURL = [NSURL fileURLWithPath:@"/bin/rm"];