Fix that SDImageCacheQueryDataWhenInMemory should response cacheType to memory cache when the in-memory cache hit (#2218)
This commit is contained in:
parent
aa4cde9389
commit
a54d1d7a2f
|
@ -394,8 +394,13 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSData *diskData = [self diskImageDataBySearchingAllPathsForKey:key];
|
NSData *diskData = [self diskImageDataBySearchingAllPathsForKey:key];
|
||||||
UIImage *diskImage = image;
|
UIImage *diskImage;
|
||||||
if (!diskImage && diskData) {
|
SDImageCacheType cacheType = SDImageCacheTypeDisk;
|
||||||
|
if (image) {
|
||||||
|
// the image is from in-memory cache
|
||||||
|
diskImage = image;
|
||||||
|
cacheType = SDImageCacheTypeMemory;
|
||||||
|
} else if (diskData) {
|
||||||
// decode image data only if in-memory cache missed
|
// decode image data only if in-memory cache missed
|
||||||
diskImage = [self diskImageForKey:key data:diskData];
|
diskImage = [self diskImageForKey:key data:diskData];
|
||||||
if (diskImage && self.config.shouldCacheImagesInMemory) {
|
if (diskImage && self.config.shouldCacheImagesInMemory) {
|
||||||
|
@ -406,10 +411,10 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
|
|
||||||
if (doneBlock) {
|
if (doneBlock) {
|
||||||
if (options & SDImageCacheQueryDiskSync) {
|
if (options & SDImageCacheQueryDiskSync) {
|
||||||
doneBlock(diskImage, diskData, SDImageCacheTypeDisk);
|
doneBlock(diskImage, diskData, cacheType);
|
||||||
} else {
|
} else {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
doneBlock(diskImage, diskData, SDImageCacheTypeDisk);
|
doneBlock(diskImage, diskData, cacheType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue