Fix the rare case when cancel an async disk cache query may cause twice callback
One is sync and another is async
This commit is contained in:
parent
cc1995b738
commit
0643cb81c3
|
@ -662,6 +662,13 @@ static NSString * _defaultDiskCacheDirectory;
|
||||||
}
|
}
|
||||||
if (doneBlock) {
|
if (doneBlock) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
// Dispatch from IO queue to main queue need time, user may call cancel during the dispatch timing
|
||||||
|
// This check is here to avoid double callback (one is from `SDImageCacheToken` in sync)
|
||||||
|
@synchronized (operation) {
|
||||||
|
if (operation.isCancelled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
doneBlock(diskImage, diskData, SDImageCacheTypeDisk);
|
doneBlock(diskImage, diskData, SDImageCacheTypeDisk);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue