Fix condition logic issue in #326
Showing
1 changed file
with
15 additions
and
11 deletions
@@ -94,19 +94,15 @@ | @@ -94,19 +94,15 @@ | ||
94 | { | 94 | { |
95 | if (operation.isCancelled) return; | 95 | if (operation.isCancelled) return; |
96 | 96 | ||
97 | - if (image) | 97 | + if ((!image || options & SDWebImageRefreshCached) && (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url])) |
98 | { | 98 | { |
99 | - completedBlock(image, nil, cacheType, YES); | ||
100 | - if (!(options & SDWebImageRefreshCached)) { | ||
101 | - @synchronized(self.runningOperations) | ||
102 | - { | ||
103 | - [self.runningOperations removeObject:operation]; | ||
104 | - } | 99 | + if (image && options & SDWebImageRefreshCached) |
100 | + { | ||
101 | + // If image was found in the cache bug SDWebImageRefreshCached is provided, notify about the cached image | ||
102 | + // AND try to re-download it in order to let a chance to NSURLCache to refresh it from server. | ||
103 | + completedBlock(image, nil, cacheType, YES); | ||
105 | } | 104 | } |
106 | - } | ||
107 | 105 | ||
108 | - if ((!image || options & SDWebImageRefreshCached) && (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url])) | ||
109 | - { | ||
110 | // download if no image or requested to refresh anyway, and download allowed by delegate | 106 | // download if no image or requested to refresh anyway, and download allowed by delegate |
111 | SDWebImageDownloaderOptions downloaderOptions = 0; | 107 | SDWebImageDownloaderOptions downloaderOptions = 0; |
112 | if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority; | 108 | if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority; |
@@ -172,7 +168,15 @@ | @@ -172,7 +168,15 @@ | ||
172 | }]; | 168 | }]; |
173 | operation.cancelBlock = ^{[subOperation cancel];}; | 169 | operation.cancelBlock = ^{[subOperation cancel];}; |
174 | } | 170 | } |
175 | - else if (!image) | 171 | + else if (image) |
172 | + { | ||
173 | + completedBlock(image, nil, cacheType, YES); | ||
174 | + @synchronized(self.runningOperations) | ||
175 | + { | ||
176 | + [self.runningOperations removeObject:operation]; | ||
177 | + } | ||
178 | + } | ||
179 | + else | ||
176 | { | 180 | { |
177 | // Image not in cache and download disallowed by delegate | 181 | // Image not in cache and download disallowed by delegate |
178 | completedBlock(nil, nil, SDImageCacheTypeNone, YES); | 182 | completedBlock(nil, nil, SDImageCacheTypeNone, YES); |
-
Please register or login to post a comment