diff --git a/SDWebImage/Core/SDImageCache.h b/SDWebImage/Core/SDImageCache.h index 0289b920..3cf9168b 100644 --- a/SDWebImage/Core/SDImageCache.h +++ b/SDWebImage/Core/SDImageCache.h @@ -323,6 +323,7 @@ typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) { * @param doneBlock The completion block. Will not get called if the operation is cancelled * * @return a SDImageCacheToken instance containing the cache operation, will callback immediately when cancelled + * @warning If you query with thumbnail cache key, you'd better not pass the thumbnail pixel size context, which is undefined behavior. */ - (nullable SDImageCacheToken *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options done:(nullable SDImageCacheQueryCompletionBlock)doneBlock; @@ -335,6 +336,7 @@ typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) { * @param doneBlock The completion block. Will not get called if the operation is cancelled * * @return a SDImageCacheToken instance containing the cache operation, will callback immediately when cancellederation, will callback immediately when cancelled + * @warning If you query with thumbnail cache key, you'd better not pass the thumbnail pixel size context, which is undefined behavior. */ - (nullable SDImageCacheToken *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context done:(nullable SDImageCacheQueryCompletionBlock)doneBlock; @@ -348,6 +350,7 @@ typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) { * @param doneBlock The completion block. Will not get called if the operation is cancelled * * @return a SDImageCacheToken instance containing the cache operation, will callback immediately when cancelled + * @warning If you query with thumbnail cache key, you'd better not pass the thumbnail pixel size context, which is undefined behavior. */ - (nullable SDImageCacheToken *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context cacheType:(SDImageCacheType)queryCacheType done:(nullable SDImageCacheQueryCompletionBlock)doneBlock; diff --git a/SDWebImage/Core/SDImageCache.m b/SDWebImage/Core/SDImageCache.m index c188adc3..84b27c30 100644 --- a/SDWebImage/Core/SDImageCache.m +++ b/SDWebImage/Core/SDImageCache.m @@ -533,8 +533,7 @@ static NSString * _defaultDiskCacheDirectory; // The disk -> memory sync logic, which should only store thumbnail image with thumbnail key // However, caller (like SDWebImageManager) will query full key, with thumbnail size, and get thubmnail image // We should add a check here, currently it's a hack - if (diskImage.sd_isThumbnail) { - NSAssert(!SDIsThumbnailKey(key), @"The input cache key %@ should not be thumbnail key", key); + if (diskImage.sd_isThumbnail && !SDIsThumbnailKey(key)) { SDImageCoderOptions *options = diskImage.sd_decodeOptions; CGSize thumbnailSize = CGSizeZero; NSValue *thumbnailSizeValue = options[SDImageCoderDecodeThumbnailPixelSize];