Skip to content

Commit

Permalink
End background task when download is cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Zorn committed Jan 30, 2012
1 parent 28e1f27 commit d3da338
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Classes/DocSetDownloadManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ - (void)stopDownload:(DocSetDownload *)download
[[NSNotificationCenter defaultCenter] postNotificationName:DocSetDownloadFinishedNotification object:download];
[self startNextDownload];
} else if (download.status == DocSetDownloadStatusExtracting) {
download.shouldCancelExtracting = YES;
}
download.shouldCancelExtracting = YES;
}
}

- (void)downloadDocSetAtURL:(NSString *)URL
Expand Down Expand Up @@ -216,6 +216,9 @@ - (void)cancel
if (self.status == DocSetDownloadStatusDownloading) {
[self.connection cancel];
self.status = DocSetDownloadStatusFinished;
if (_backgroundTask != UIBackgroundTaskInvalid) {
[[UIApplication sharedApplication] endBackgroundTask:_backgroundTask];
}
}
}

Expand Down Expand Up @@ -273,11 +276,10 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection
xar_file_t f = xar_file_first(x, i);
NSInteger filesExtracted = 0;
do {
if (self.shouldCancelExtracting) {
NSLog(@"Extracting cancelled");
break;
}

if (self.shouldCancelExtracting) {
NSLog(@"Extracting cancelled");
break;
}
if (f) {
const char *name = NULL;
xar_prop_get(f, "name", &name);
Expand Down

0 comments on commit d3da338

Please sign in to comment.