Skip to content

Commit

Permalink
The code from SDWebImageDownloaderOperation connection:didFailWithErr…
Browse files Browse the repository at this point in the history
…or: should match the code from connectionDidFinishLoading:. This fixes #872
  • Loading branch information
bpoplauschi committed Nov 2, 2014
1 parent 936f47c commit 7f39e5e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions SDWebImage/SDWebImageDownloaderOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)aConnection {
responseFromCached = NO;
}

if (completionBlock)
{
if (completionBlock) {
if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached) {
completionBlock(nil, nil, nil, YES);
}
Expand All @@ -364,13 +363,17 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)aConnection {
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
CFRunLoopStop(CFRunLoopGetCurrent());
[[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:nil];
@synchronized(self) {
CFRunLoopStop(CFRunLoopGetCurrent());
self.thread = nil;
self.connection = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:nil];
}

if (self.completedBlock) {
self.completedBlock(nil, nil, error, YES);
}

self.completionBlock = nil;
[self done];
}

Expand Down

0 comments on commit 7f39e5e

Please sign in to comment.