Fix wrong image cache type when disk and memory cache missed

This commit is contained in:
zhongwuzw 2018-11-14 16:18:50 +08:00
parent e056218bbf
commit 5611863f6a
1 changed files with 2 additions and 1 deletions

View File

@ -535,12 +535,13 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
@autoreleasepool { @autoreleasepool {
NSData *diskData = [self diskImageDataBySearchingAllPathsForKey:key]; NSData *diskData = [self diskImageDataBySearchingAllPathsForKey:key];
UIImage *diskImage; UIImage *diskImage;
SDImageCacheType cacheType = SDImageCacheTypeDisk; SDImageCacheType cacheType = SDImageCacheTypeNone;
if (image) { if (image) {
// the image is from in-memory cache // the image is from in-memory cache
diskImage = image; diskImage = image;
cacheType = SDImageCacheTypeMemory; cacheType = SDImageCacheTypeMemory;
} else if (diskData) { } else if (diskData) {
cacheType = SDImageCacheTypeDisk;
// decode image data only if in-memory cache missed // decode image data only if in-memory cache missed
diskImage = [self diskImageForKey:key data:diskData options:options]; diskImage = [self diskImageForKey:key data:diskData options:options];
if (diskImage && self.config.shouldCacheImagesInMemory) { if (diskImage && self.config.shouldCacheImagesInMemory) {