Avoid store original disk cache again when using thumbnail or transformer from the full size data

This solve #3395
This commit is contained in:
DreamPiggy 2022-11-08 16:44:40 +08:00
parent 5a89f80816
commit f93cf96832
1 changed files with 7 additions and 0 deletions

View File

@ -565,6 +565,13 @@ static id<SDImageLoader> _defaultImageLoader;
} }
id<SDWebImageCacheSerializer> cacheSerializer = context[SDWebImageContextCacheSerializer]; id<SDWebImageCacheSerializer> cacheSerializer = context[SDWebImageContextCacheSerializer];
// If the original cacheType is disk, since we don't need to store the original data again
// Strip the disk from the originalStoreCacheType
if (cacheType == SDImageCacheTypeDisk) {
if (originalStoreCacheType == SDImageCacheTypeDisk) originalStoreCacheType = SDImageCacheTypeNone;
if (originalStoreCacheType == SDImageCacheTypeAll) originalStoreCacheType = SDImageCacheTypeMemory;
}
// Get original cache key generation without transformer // Get original cache key generation without transformer
NSString *key = [self originalCacheKeyForURL:url context:context]; NSString *key = [self originalCacheKeyForURL:url context:context];
if (finished && cacheSerializer && (originalStoreCacheType == SDImageCacheTypeDisk || originalStoreCacheType == SDImageCacheTypeAll)) { if (finished && cacheSerializer && (originalStoreCacheType == SDImageCacheTypeDisk || originalStoreCacheType == SDImageCacheTypeAll)) {