|
@@ -233,6 +233,15 @@
|
|
|
[self.downloadingOperationArr removeAllObjects];
|
|
|
}
|
|
|
|
|
|
+#pragma mark 重新启动因为网络失败而停止的任务
|
|
|
+- (void)reDownloadNetworkTaskBy:(NSString*)url
|
|
|
+{
|
|
|
+ @synchronized (self) {
|
|
|
+ [self.downloadWaitingUrlArr insertObject:url atIndex:0];
|
|
|
+ }
|
|
|
+
|
|
|
+ [self beginDownload];
|
|
|
+}
|
|
|
|
|
|
#pragma mark - <NSURLSessionDataDelegate>
|
|
|
|
|
@@ -442,6 +451,14 @@ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(error && error.code == -1005){//网络中断
|
|
|
+ //延时几秒再次启动这个任务
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [self reDownloadNetworkTaskBy:operation.url];
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if(operation.isManualCancel){
|
|
|
[self beginDownload];
|
|
|
return;
|