Merge pull request #3661 from dreampiggy/project/remove_assert_thumbnail_cache_key

Temp remove the assert when thumbnail cache key used with thumbnail context , this may be changed later
This commit is contained in:
DreamPiggy 2024-01-10 14:25:34 +08:00 committed by GitHub
commit 956e29ccb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -323,6 +323,7 @@ typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) {
* @param doneBlock The completion block. Will not get called if the operation is cancelled * @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 * @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; - (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 * @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 * @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; - (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 * @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 * @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; - (nullable SDImageCacheToken *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context cacheType:(SDImageCacheType)queryCacheType done:(nullable SDImageCacheQueryCompletionBlock)doneBlock;

View File

@ -533,8 +533,7 @@ static NSString * _defaultDiskCacheDirectory;
// The disk -> memory sync logic, which should only store thumbnail image with thumbnail key // 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 // 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 // We should add a check here, currently it's a hack
if (diskImage.sd_isThumbnail) { if (diskImage.sd_isThumbnail && !SDIsThumbnailKey(key)) {
NSAssert(!SDIsThumbnailKey(key), @"The input cache key %@ should not be thumbnail key", key);
SDImageCoderOptions *options = diskImage.sd_decodeOptions; SDImageCoderOptions *options = diskImage.sd_decodeOptions;
CGSize thumbnailSize = CGSizeZero; CGSize thumbnailSize = CGSizeZero;
NSValue *thumbnailSizeValue = options[SDImageCoderDecodeThumbnailPixelSize]; NSValue *thumbnailSizeValue = options[SDImageCoderDecodeThumbnailPixelSize];