From f93cf968327635b61bf0a9fac5cc0de0dcc398ec Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Tue, 8 Nov 2022 16:44:40 +0800 Subject: [PATCH] Avoid store original disk cache again when using thumbnail or transformer from the full size data This solve #3395 --- SDWebImage/Core/SDWebImageManager.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SDWebImage/Core/SDWebImageManager.m b/SDWebImage/Core/SDWebImageManager.m index 8ffc16ee..6bb7c147 100644 --- a/SDWebImage/Core/SDWebImageManager.m +++ b/SDWebImage/Core/SDWebImageManager.m @@ -565,6 +565,13 @@ static id _defaultImageLoader; } id 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 NSString *key = [self originalCacheKeyForURL:url context:context]; if (finished && cacheSerializer && (originalStoreCacheType == SDImageCacheTypeDisk || originalStoreCacheType == SDImageCacheTypeAll)) {