fix disk image fetch bug
This commit is contained in:
parent
83116a97bb
commit
ddbeaa1cdc
|
@ -537,13 +537,11 @@ static NSString * _defaultDiskCacheDirectory;
|
||||||
SDImageCacheType cacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
SDImageCacheType cacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
||||||
shouldCacheToMomery = (cacheType == SDImageCacheTypeAll || cacheType == SDImageCacheTypeMemory);
|
shouldCacheToMomery = (cacheType == SDImageCacheTypeAll || cacheType == SDImageCacheTypeMemory);
|
||||||
}
|
}
|
||||||
if (shouldCacheToMomery) {
|
// 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 context:context];
|
||||||
diskImage = [self diskImageForKey:key data:diskData options:options context:context];
|
if (shouldCacheToMomery && diskImage && self.config.shouldCacheImagesInMemory) {
|
||||||
if (diskImage && self.config.shouldCacheImagesInMemory) {
|
NSUInteger cost = diskImage.sd_memoryCost;
|
||||||
NSUInteger cost = diskImage.sd_memoryCost;
|
[self.memoryCache setObject:diskImage forKey:key cost:cost];
|
||||||
[self.memoryCache setObject:diskImage forKey:key cost:cost];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -632,6 +632,7 @@ static NSString *kTestImageKeyPNG = @"TestImageKey.png";
|
||||||
[[SDImageCache sharedImageCache] storeImageDataToDisk:data forKey:kTestImageKeyJPEG];
|
[[SDImageCache sharedImageCache] storeImageDataToDisk:data forKey:kTestImageKeyJPEG];
|
||||||
|
|
||||||
[[SDImageCachesManager sharedManager] queryImageForKey:kTestImageKeyJPEG options:0 context:@{SDWebImageContextStoreCacheType : @(SDImageCacheTypeDisk)} cacheType:SDImageCacheTypeAll completion:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
|
[[SDImageCachesManager sharedManager] queryImageForKey:kTestImageKeyJPEG options:0 context:@{SDWebImageContextStoreCacheType : @(SDImageCacheTypeDisk)} cacheType:SDImageCacheTypeAll completion:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
|
||||||
|
expect(image).notTo.beNil();
|
||||||
expect([[SDImageCache sharedImageCache] imageFromMemoryCacheForKey:kTestImageKeyJPEG]).beNil();
|
expect([[SDImageCache sharedImageCache] imageFromMemoryCacheForKey:kTestImageKeyJPEG]).beNil();
|
||||||
[expectation fulfill];
|
[expectation fulfill];
|
||||||
}];
|
}];
|
||||||
|
|
Loading…
Reference in New Issue