@@ -595,21 +595,27 @@ - (NSNumber *)_numberForEntryAtIndex:(NSInteger)index {
595595- (void )saveMetadata {
596596 [_lock lock ];
597597
598- NSArray *mruArray = [_MRUEntries array ];
599598 NSDictionary *metadataDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
600- _indexMap, FICImageTableIndexMapKey,
601- _sourceImageMap, FICImageTableContextMapKey,
602- mruArray, FICImageTableMRUArrayKey,
603- _imageFormatDictionary, FICImageTableFormatKey, nil ];
604-
605- NSData *data = [NSPropertyListSerialization dataWithPropertyList: metadataDictionary format: NSPropertyListBinaryFormat_v1_0 options: 0 error: NULL ];
606- BOOL fileWriteResult = [data writeToFile: [self metadataFilePath ] atomically: NO ];
607- if (fileWriteResult == NO ) {
608- NSString *message = [NSString stringWithFormat: @" *** FIC Error: %s couldn't write metadata for format %@ " , __PRETTY_FUNCTION__, [_imageFormat name ]];
609- [[FICImageCache sharedImageCache ] _logMessage: message];
610- }
611-
599+ [_indexMap copy ], FICImageTableIndexMapKey,
600+ [_sourceImageMap copy ], FICImageTableContextMapKey,
601+ [[_MRUEntries array ] copy ], FICImageTableMRUArrayKey,
602+ [_imageFormatDictionary copy ], FICImageTableFormatKey, nil ];
612603 [_lock unlock ];
604+
605+ static dispatch_queue_t __metadataQueue = nil ;
606+ static dispatch_once_t onceToken;
607+ dispatch_once (&onceToken, ^{
608+ __metadataQueue = dispatch_queue_create (" com.path.FastImageCache.ImageTableMetadataQueue" , NULL );
609+ });
610+
611+ dispatch_async (__metadataQueue, ^{
612+ NSData *data = [NSPropertyListSerialization dataWithPropertyList: metadataDictionary format: NSPropertyListBinaryFormat_v1_0 options: 0 error: NULL ];
613+ BOOL fileWriteResult = [data writeToFile: [self metadataFilePath ] atomically: NO ];
614+ if (fileWriteResult == NO ) {
615+ NSString *message = [NSString stringWithFormat: @" *** FIC Error: %s couldn't write metadata for format %@ " , __PRETTY_FUNCTION__, [_imageFormat name ]];
616+ [[FICImageCache sharedImageCache ] _logMessage: message];
617+ }
618+ });
613619}
614620
615621- (void )_loadMetadata {
0 commit comments