Fix the issue when multiple request for same url failed, the completedBlock will callback more times

This commit is contained in:
DreamPiggy 2023-02-18 17:27:13 +08:00
parent 9cf8d125f5
commit b25864cc71
1 changed files with 2 additions and 1 deletions

View File

@ -601,7 +601,8 @@ didReceiveResponse:(NSURLResponse *)response
CGSize imageSize = image.size;
if (imageSize.width == 0 || imageSize.height == 0) {
NSString *description = image == nil ? @"Downloaded image decode failed" : @"Downloaded image has 0 pixels";
[self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorBadImageData userInfo:@{NSLocalizedDescriptionKey : description}]];
NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorBadImageData userInfo:@{NSLocalizedDescriptionKey : description}];
[self callCompletionBlockWithToken:token image:nil imageData:nil error:error finished:YES];
} else {
[self callCompletionBlockWithToken:token image:image imageData:imageData error:nil finished:YES];
}