|
@@ -112,6 +112,26 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
return key;
|
|
|
}
|
|
|
|
|
|
+- (nullable NSString *)originalCacheKeyForURL:(nullable NSURL *)url context:(nullable SDWebImageContext *)context {
|
|
|
+ if (!url) {
|
|
|
+ return @"";
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *key;
|
|
|
+ // Cache Key Filter
|
|
|
+ id<SDWebImageCacheKeyFilter> cacheKeyFilter = self.cacheKeyFilter;
|
|
|
+ if (context[SDWebImageContextCacheKeyFilter]) {
|
|
|
+ cacheKeyFilter = context[SDWebImageContextCacheKeyFilter];
|
|
|
+ }
|
|
|
+ if (cacheKeyFilter) {
|
|
|
+ key = [cacheKeyFilter cacheKeyForURL:url];
|
|
|
+ } else {
|
|
|
+ key = url.absoluteString;
|
|
|
+ }
|
|
|
+
|
|
|
+ return key;
|
|
|
+}
|
|
|
+
|
|
|
- (nullable NSString *)cacheKeyForURL:(nullable NSURL *)url context:(nullable SDWebImageContext *)context {
|
|
|
if (!url) {
|
|
|
return @"";
|
|
@@ -278,10 +298,14 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
[self callCompletionBlockForOperation:operation completion:completedBlock error:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorCancelled userInfo:@{NSLocalizedDescriptionKey : @"Operation cancelled by user during querying the cache"}] url:url];
|
|
|
[self safelyRemoveOperationFromRunning:operation];
|
|
|
return;
|
|
|
- } else if (context[SDWebImageContextImageTransformer] && !cachedImage) {
|
|
|
- // Have a chance to query original cache instead of downloading
|
|
|
- [self callOriginalCacheProcessForOperation:operation url:url options:options context:context progress:progressBlock completed:completedBlock];
|
|
|
- return;
|
|
|
+ } else if (!cachedImage) {
|
|
|
+ BOOL mayInOriginalCache = context[SDWebImageContextImageTransformer] || context[SDWebImageContextImageThumbnailPixelSize];
|
|
|
+ // Have a chance to query original cache instead of downloading, then applying transform
|
|
|
+ // Thumbnail decoding is done inside SDImageCache's decoding part, which does not need post processing for transform
|
|
|
+ if (mayInOriginalCache) {
|
|
|
+ [self callOriginalCacheProcessForOperation:operation url:url options:options context:context progress:progressBlock completed:completedBlock];
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Continue download process
|
|
@@ -321,10 +345,8 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
// Check whether we should query original cache
|
|
|
BOOL shouldQueryOriginalCache = (originalQueryCacheType != SDImageCacheTypeNone);
|
|
|
if (shouldQueryOriginalCache) {
|
|
|
- // Disable transformer for original cache key generation
|
|
|
- SDWebImageMutableContext *tempContext = [context mutableCopy];
|
|
|
- tempContext[SDWebImageContextImageTransformer] = [NSNull null];
|
|
|
- NSString *key = [self cacheKeyForURL:url context:tempContext];
|
|
|
+ // Get original cache key generation without transformer/thumbnail
|
|
|
+ NSString *key = [self originalCacheKeyForURL:url context:context];
|
|
|
@weakify(operation);
|
|
|
operation.cacheOperation = [imageCache queryImageForKey:key options:options context:context cacheType:originalQueryCacheType completion:^(UIImage * _Nullable cachedImage, NSData * _Nullable cachedData, SDImageCacheType cacheType) {
|
|
|
@strongify(operation);
|
|
@@ -333,20 +355,20 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
[self callCompletionBlockForOperation:operation completion:completedBlock error:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorCancelled userInfo:@{NSLocalizedDescriptionKey : @"Operation cancelled by user during querying the cache"}] url:url];
|
|
|
[self safelyRemoveOperationFromRunning:operation];
|
|
|
return;
|
|
|
- } else if (context[SDWebImageContextImageTransformer] && !cachedImage) {
|
|
|
+ } else if (!cachedImage) {
|
|
|
// Original image cache miss. Continue download process
|
|
|
- [self callDownloadProcessForOperation:operation url:url options:options context:context cachedImage:nil cachedData:nil cacheType:originalQueryCacheType progress:progressBlock completed:completedBlock];
|
|
|
+ [self callDownloadProcessForOperation:operation url:url options:options context:context cachedImage:nil cachedData:nil cacheType:SDImageCacheTypeNone progress:progressBlock completed:completedBlock];
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Use the store cache process instead of downloading, and ignore .refreshCached option for now
|
|
|
- [self callStoreCacheProcessForOperation:operation url:url options:options context:context downloadedImage:cachedImage downloadedData:cachedData finished:YES progress:progressBlock completed:completedBlock];
|
|
|
+ [self callStoreCacheProcessForOperation:operation url:url options:options context:context downloadedImage:cachedImage downloadedData:cachedData cacheType:cacheType finished:YES completed:completedBlock];
|
|
|
|
|
|
[self safelyRemoveOperationFromRunning:operation];
|
|
|
}];
|
|
|
} else {
|
|
|
// Continue download process
|
|
|
- [self callDownloadProcessForOperation:operation url:url options:options context:context cachedImage:nil cachedData:nil cacheType:originalQueryCacheType progress:progressBlock completed:completedBlock];
|
|
|
+ [self callDownloadProcessForOperation:operation url:url options:options context:context cachedImage:nil cachedData:nil cacheType:SDImageCacheTypeNone progress:progressBlock completed:completedBlock];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -420,7 +442,7 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
SD_UNLOCK(self->_failedURLsLock);
|
|
|
}
|
|
|
// Continue store cache process
|
|
|
- [self callStoreCacheProcessForOperation:operation url:url options:options context:context downloadedImage:downloadedImage downloadedData:downloadedData finished:finished progress:progressBlock completed:completedBlock];
|
|
|
+ [self callStoreCacheProcessForOperation:operation url:url options:options context:context downloadedImage:downloadedImage downloadedData:downloadedData cacheType:SDImageCacheTypeNone finished:finished completed:completedBlock];
|
|
|
}
|
|
|
|
|
|
if (finished) {
|
|
@@ -444,8 +466,8 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
context:(SDWebImageContext *)context
|
|
|
downloadedImage:(nullable UIImage *)downloadedImage
|
|
|
downloadedData:(nullable NSData *)downloadedData
|
|
|
+ cacheType:(SDImageCacheType)cacheType
|
|
|
finished:(BOOL)finished
|
|
|
- progress:(nullable SDImageLoaderProgressBlock)progressBlock
|
|
|
completed:(nullable SDInternalCompletionBlock)completedBlock {
|
|
|
// Grab the image cache to use, choose standalone original cache firstly
|
|
|
id<SDImageCache> imageCache;
|
|
@@ -459,6 +481,7 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
imageCache = self.imageCache;
|
|
|
}
|
|
|
}
|
|
|
+ BOOL waitStoreCache = SD_OPTIONS_CONTAINS(options, SDWebImageWaitStoreCache);
|
|
|
// the target image store cache type
|
|
|
SDImageCacheType storeCacheType = SDImageCacheTypeAll;
|
|
|
if (context[SDWebImageContextStoreCacheType]) {
|
|
@@ -469,44 +492,53 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
if (context[SDWebImageContextOriginalStoreCacheType]) {
|
|
|
originalStoreCacheType = [context[SDWebImageContextOriginalStoreCacheType] integerValue];
|
|
|
}
|
|
|
- // Disable transformer for original cache key generation
|
|
|
- SDWebImageMutableContext *tempContext = [context mutableCopy];
|
|
|
- tempContext[SDWebImageContextImageTransformer] = [NSNull null];
|
|
|
- NSString *key = [self cacheKeyForURL:url context:tempContext];
|
|
|
id<SDImageTransformer> transformer = context[SDWebImageContextImageTransformer];
|
|
|
if (![transformer conformsToProtocol:@protocol(SDImageTransformer)]) {
|
|
|
transformer = nil;
|
|
|
}
|
|
|
id<SDWebImageCacheSerializer> cacheSerializer = context[SDWebImageContextCacheSerializer];
|
|
|
|
|
|
+ // transformer check
|
|
|
BOOL shouldTransformImage = downloadedImage && transformer;
|
|
|
shouldTransformImage = shouldTransformImage && (!downloadedImage.sd_isAnimated || (options & SDWebImageTransformAnimatedImage));
|
|
|
shouldTransformImage = shouldTransformImage && (!downloadedImage.sd_isVector || (options & SDWebImageTransformVectorImage));
|
|
|
- BOOL shouldCacheOriginal = downloadedImage && finished;
|
|
|
+ // thumbnail check
|
|
|
+ BOOL shouldThumbnailImage = context[SDWebImageContextImageThumbnailPixelSize] != nil || downloadedImage.sd_decodeOptions[SDImageCoderDecodeThumbnailPixelSize] != nil;
|
|
|
+
|
|
|
+ BOOL shouldCacheOriginal = downloadedImage && finished && cacheType == SDImageCacheTypeNone;
|
|
|
|
|
|
// if available, store original image to cache
|
|
|
if (shouldCacheOriginal) {
|
|
|
+ // Get original cache key generation without transformer/thumbnail
|
|
|
+ NSString *key = [self originalCacheKeyForURL:url context:context];
|
|
|
// normally use the store cache type, but if target image is transformed, use original store cache type instead
|
|
|
- SDImageCacheType targetStoreCacheType = shouldTransformImage ? originalStoreCacheType : storeCacheType;
|
|
|
- if (cacheSerializer && (targetStoreCacheType == SDImageCacheTypeDisk || targetStoreCacheType == SDImageCacheTypeAll)) {
|
|
|
+ SDImageCacheType targetStoreCacheType = (shouldTransformImage || shouldThumbnailImage) ? originalStoreCacheType : storeCacheType;
|
|
|
+ UIImage *fullSizeImage = downloadedImage;
|
|
|
+ if (shouldThumbnailImage) {
|
|
|
+ // Thumbnail decoding does not keep original image
|
|
|
+ // Here we only store the original data to disk for original cache key
|
|
|
+ // Store thumbnail image to memory for thumbnail cache key later in `storeTransformCacheProcess`
|
|
|
+ fullSizeImage = nil;
|
|
|
+ }
|
|
|
+ if (fullSizeImage && cacheSerializer && (targetStoreCacheType == SDImageCacheTypeDisk || targetStoreCacheType == SDImageCacheTypeAll)) {
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
|
|
@autoreleasepool {
|
|
|
- NSData *cacheData = [cacheSerializer cacheDataWithImage:downloadedImage originalData:downloadedData imageURL:url];
|
|
|
- [self storeImage:downloadedImage imageData:cacheData forKey:key imageCache:imageCache cacheType:targetStoreCacheType options:options context:context completion:^{
|
|
|
+ NSData *cacheData = [cacheSerializer cacheDataWithImage:fullSizeImage originalData:downloadedData imageURL:url];
|
|
|
+ [self storeImage:fullSizeImage imageData:cacheData forKey:key imageCache:imageCache cacheType:targetStoreCacheType waitStoreCache:waitStoreCache completion:^{
|
|
|
// Continue transform process
|
|
|
- [self callTransformProcessForOperation:operation url:url options:options context:context originalImage:downloadedImage originalData:downloadedData finished:finished progress:progressBlock completed:completedBlock];
|
|
|
+ [self callTransformProcessForOperation:operation url:url options:options context:context originalImage:downloadedImage originalData:downloadedData cacheType:cacheType finished:finished completed:completedBlock];
|
|
|
}];
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- [self storeImage:downloadedImage imageData:downloadedData forKey:key imageCache:imageCache cacheType:targetStoreCacheType options:options context:context completion:^{
|
|
|
+ [self storeImage:fullSizeImage imageData:downloadedData forKey:key imageCache:imageCache cacheType:targetStoreCacheType waitStoreCache:waitStoreCache completion:^{
|
|
|
// Continue transform process
|
|
|
- [self callTransformProcessForOperation:operation url:url options:options context:context originalImage:downloadedImage originalData:downloadedData finished:finished progress:progressBlock completed:completedBlock];
|
|
|
+ [self callTransformProcessForOperation:operation url:url options:options context:context originalImage:downloadedImage originalData:downloadedData cacheType:cacheType finished:finished completed:completedBlock];
|
|
|
}];
|
|
|
}
|
|
|
} else {
|
|
|
// Continue transform process
|
|
|
- [self callTransformProcessForOperation:operation url:url options:options context:context originalImage:downloadedImage originalData:downloadedData finished:finished progress:progressBlock completed:completedBlock];
|
|
|
+ [self callTransformProcessForOperation:operation url:url options:options context:context originalImage:downloadedImage originalData:downloadedData cacheType:cacheType finished:finished completed:completedBlock];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -517,56 +549,133 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
context:(SDWebImageContext *)context
|
|
|
originalImage:(nullable UIImage *)originalImage
|
|
|
originalData:(nullable NSData *)originalData
|
|
|
+ cacheType:(SDImageCacheType)cacheType
|
|
|
finished:(BOOL)finished
|
|
|
- progress:(nullable SDImageLoaderProgressBlock)progressBlock
|
|
|
completed:(nullable SDInternalCompletionBlock)completedBlock {
|
|
|
- // Grab the image cache to use
|
|
|
- id<SDImageCache> imageCache;
|
|
|
- if ([context[SDWebImageContextImageCache] conformsToProtocol:@protocol(SDImageCache)]) {
|
|
|
- imageCache = context[SDWebImageContextImageCache];
|
|
|
- } else {
|
|
|
- imageCache = self.imageCache;
|
|
|
- }
|
|
|
// the target image store cache type
|
|
|
SDImageCacheType storeCacheType = SDImageCacheTypeAll;
|
|
|
if (context[SDWebImageContextStoreCacheType]) {
|
|
|
storeCacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
|
|
}
|
|
|
- // transformed cache key
|
|
|
- NSString *key = [self cacheKeyForURL:url context:context];
|
|
|
id<SDImageTransformer> transformer = context[SDWebImageContextImageTransformer];
|
|
|
if (![transformer conformsToProtocol:@protocol(SDImageTransformer)]) {
|
|
|
transformer = nil;
|
|
|
}
|
|
|
- id<SDWebImageCacheSerializer> cacheSerializer = context[SDWebImageContextCacheSerializer];
|
|
|
|
|
|
+ // transformer check
|
|
|
BOOL shouldTransformImage = originalImage && transformer;
|
|
|
shouldTransformImage = shouldTransformImage && (!originalImage.sd_isAnimated || (options & SDWebImageTransformAnimatedImage));
|
|
|
shouldTransformImage = shouldTransformImage && (!originalImage.sd_isVector || (options & SDWebImageTransformVectorImage));
|
|
|
- // if available, store transformed image to cache
|
|
|
+
|
|
|
+ // thumbnail check
|
|
|
+ // This exist when previous thumbnail pipeline callback into next full size pipeline, because we share the same URL download but need different image
|
|
|
+ // Actually this is a hack, we attach the metadata into image object, which should design a better concept like `ImageInfo` and keep that around
|
|
|
+ // Redecode need the full size data (progressive decoding or third-party loaders may callback nil data)
|
|
|
+ BOOL shouldRedecodeFullImage = originalData && cacheType == SDImageCacheTypeNone;
|
|
|
+ if (shouldRedecodeFullImage) {
|
|
|
+ // If the retuened image decode options exist (some loaders impl does not use `SDImageLoaderDecode`) but does not match the options we provide, redecode
|
|
|
+ SDImageCoderOptions *returnedDecodeOptions = originalImage.sd_decodeOptions;
|
|
|
+ if (returnedDecodeOptions) {
|
|
|
+ SDImageCoderOptions *decodeOptions = SDGetDecodeOptionsFromContext(context, options, url.absoluteString);
|
|
|
+ shouldRedecodeFullImage = ![returnedDecodeOptions isEqualToDictionary:decodeOptions];
|
|
|
+ } else {
|
|
|
+ shouldRedecodeFullImage = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (shouldTransformImage) {
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
|
|
@autoreleasepool {
|
|
|
- UIImage *transformedImage = [transformer transformedImageWithImage:originalImage forKey:key];
|
|
|
- if (transformedImage && finished) {
|
|
|
- BOOL imageWasTransformed = ![transformedImage isEqual:originalImage];
|
|
|
- NSData *cacheData;
|
|
|
- // pass nil if the image was transformed, so we can recalculate the data from the image
|
|
|
- if (cacheSerializer && (storeCacheType == SDImageCacheTypeDisk || storeCacheType == SDImageCacheTypeAll)) {
|
|
|
- cacheData = [cacheSerializer cacheDataWithImage:transformedImage originalData:(imageWasTransformed ? nil : originalData) imageURL:url];
|
|
|
+ // transformed/thumbnailed cache key
|
|
|
+ NSString *key = [self cacheKeyForURL:url context:context];
|
|
|
+ // Case that transformer one thumbnail, which this time need full pixel image
|
|
|
+ UIImage *fullSizeImage = originalImage;
|
|
|
+ BOOL imageWasRedecoded = NO;
|
|
|
+ if (shouldRedecodeFullImage) {
|
|
|
+ fullSizeImage = SDImageCacheDecodeImageData(originalData, key, options, context);
|
|
|
+ if (fullSizeImage) {
|
|
|
+ imageWasRedecoded = YES;
|
|
|
} else {
|
|
|
- cacheData = (imageWasTransformed ? nil : originalData);
|
|
|
+ imageWasRedecoded = NO;
|
|
|
+ fullSizeImage = originalImage; // Fallback
|
|
|
}
|
|
|
- [self storeImage:transformedImage imageData:cacheData forKey:key imageCache:imageCache cacheType:storeCacheType options:options context:context completion:^{
|
|
|
- [self callCompletionBlockForOperation:operation completion:completedBlock image:transformedImage data:originalData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url];
|
|
|
- }];
|
|
|
+ }
|
|
|
+ UIImage *transformedImage = [transformer transformedImageWithImage:fullSizeImage forKey:key];
|
|
|
+ if (transformedImage && finished) {
|
|
|
+ BOOL imageWasTransformed = ![transformedImage isEqual:fullSizeImage];
|
|
|
+ // Continue store transform cache process
|
|
|
+ [self callStoreTransformCacheProcessForOperation:operation url:url options:options context:context image:transformedImage data:originalData cacheType:cacheType finished:finished transformed:imageWasTransformed || imageWasRedecoded completed:completedBlock];
|
|
|
+ } else {
|
|
|
+ // Continue store transform cache process
|
|
|
+ [self callStoreTransformCacheProcessForOperation:operation url:url options:options context:context image:fullSizeImage data:originalData cacheType:cacheType finished:finished transformed:imageWasRedecoded completed:completedBlock];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (shouldRedecodeFullImage) {
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
|
|
+ @autoreleasepool {
|
|
|
+ // Re-decode because the returned image does not match current request pipeline's context
|
|
|
+ UIImage *fullSizeImage = SDImageCacheDecodeImageData(originalData, url.absoluteString, options, context);
|
|
|
+ BOOL imageWasRedecoded = NO;
|
|
|
+ if (fullSizeImage) {
|
|
|
+ imageWasRedecoded = YES;
|
|
|
} else {
|
|
|
- [self callCompletionBlockForOperation:operation completion:completedBlock image:transformedImage data:originalData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url];
|
|
|
+ imageWasRedecoded = NO;
|
|
|
+ fullSizeImage = originalImage; // Fallback
|
|
|
}
|
|
|
+ // Continue store transform cache process
|
|
|
+ [self callStoreTransformCacheProcessForOperation:operation url:url options:options context:context image:fullSizeImage data:originalData cacheType:cacheType finished:finished transformed:imageWasRedecoded completed:completedBlock];
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- [self callCompletionBlockForOperation:operation completion:completedBlock image:originalImage data:originalData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url];
|
|
|
+ // Continue store transform cache process
|
|
|
+ [self callStoreTransformCacheProcessForOperation:operation url:url options:options context:context image:originalImage data:originalData cacheType:cacheType finished:finished transformed:NO completed:completedBlock];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)callStoreTransformCacheProcessForOperation:(nonnull SDWebImageCombinedOperation *)operation
|
|
|
+ url:(nonnull NSURL *)url
|
|
|
+ options:(SDWebImageOptions)options
|
|
|
+ context:(SDWebImageContext *)context
|
|
|
+ image:(nullable UIImage *)image
|
|
|
+ data:(nullable NSData *)data
|
|
|
+ cacheType:(SDImageCacheType)cacheType
|
|
|
+ finished:(BOOL)finished
|
|
|
+ transformed:(BOOL)transformed
|
|
|
+ completed:(nullable SDInternalCompletionBlock)completedBlock {
|
|
|
+ // Grab the image cache to use
|
|
|
+ id<SDImageCache> imageCache;
|
|
|
+ if ([context[SDWebImageContextImageCache] conformsToProtocol:@protocol(SDImageCache)]) {
|
|
|
+ imageCache = context[SDWebImageContextImageCache];
|
|
|
+ } else {
|
|
|
+ imageCache = self.imageCache;
|
|
|
+ }
|
|
|
+ BOOL waitStoreCache = SD_OPTIONS_CONTAINS(options, SDWebImageWaitStoreCache);
|
|
|
+ // the target image store cache type
|
|
|
+ SDImageCacheType storeCacheType = SDImageCacheTypeAll;
|
|
|
+ if (context[SDWebImageContextStoreCacheType]) {
|
|
|
+ storeCacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
|
|
+ }
|
|
|
+ id<SDWebImageCacheSerializer> cacheSerializer = context[SDWebImageContextCacheSerializer];
|
|
|
+ // thumbnail check
|
|
|
+ BOOL shouldThumbnailImage = context[SDWebImageContextImageThumbnailPixelSize] != nil || image.sd_decodeOptions[SDImageCoderDecodeThumbnailPixelSize] != nil;
|
|
|
+
|
|
|
+ // Store the transformed/thumbnail image into the cache
|
|
|
+ if (transformed || shouldThumbnailImage) {
|
|
|
+ NSData *cacheData;
|
|
|
+ // pass nil if the image was transformed/thumbnailed, so we can recalculate the data from the image
|
|
|
+ if (cacheSerializer && (storeCacheType == SDImageCacheTypeDisk || storeCacheType == SDImageCacheTypeAll)) {
|
|
|
+ cacheData = [cacheSerializer cacheDataWithImage:image originalData:nil imageURL:url];
|
|
|
+ } else {
|
|
|
+ cacheData = nil;
|
|
|
+ }
|
|
|
+ // transformed/thumbnailed cache key
|
|
|
+ NSString *key = [self cacheKeyForURL:url context:context];
|
|
|
+ [self storeImage:image imageData:cacheData forKey:key imageCache:imageCache cacheType:storeCacheType waitStoreCache:waitStoreCache completion:^{
|
|
|
+ [self callCompletionBlockForOperation:operation completion:completedBlock image:image data:data error:nil cacheType:cacheType finished:finished url:url];
|
|
|
+ }];
|
|
|
+ } else {
|
|
|
+ [self callCompletionBlockForOperation:operation completion:completedBlock image:image data:data error:nil cacheType:cacheType finished:finished url:url];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -586,10 +695,8 @@ static id<SDImageLoader> _defaultImageLoader;
|
|
|
forKey:(nullable NSString *)key
|
|
|
imageCache:(nonnull id<SDImageCache>)imageCache
|
|
|
cacheType:(SDImageCacheType)cacheType
|
|
|
- options:(SDWebImageOptions)options
|
|
|
- context:(nullable SDWebImageContext *)context
|
|
|
+ waitStoreCache:(BOOL)waitStoreCache
|
|
|
completion:(nullable SDWebImageNoParamsBlock)completion {
|
|
|
- BOOL waitStoreCache = SD_OPTIONS_CONTAINS(options, SDWebImageWaitStoreCache);
|
|
|
// Check whether we should wait the store cache finished. If not, callback immediately
|
|
|
[imageCache storeImage:image imageData:data forKey:key cacheType:cacheType completion:^{
|
|
|
if (waitStoreCache) {
|