|
|
@@ -411,7 +411,7 @@ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {
|
|
|
|
|
|
// 获得已经下载的文件大小
|
|
|
operation.currentSize += data.length;
|
|
|
- HLog(@"currentSize:%lld---progress:%.2f", operation.currentSize, 1.00*operation.currentSize/operation.totalSize);
|
|
|
+ HLog(@"当前线程:%@ -----currentSize:%lld---progress:%.2f",[NSThread currentThread], operation.currentSize, 1.00*operation.currentSize/operation.totalSize);
|
|
|
|
|
|
// 写入文件
|
|
|
if(operation.handle){
|
|
|
@@ -488,16 +488,21 @@ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:nasDownloadTaskExeError object:nil userInfo:@{@"operation" : operation}];
|
|
|
}
|
|
|
|
|
|
-//外面的下载数据跳的太频繁 控制下
|
|
|
-static int nasDownloadTaskExeingNotNum = 0;
|
|
|
+
|
|
|
|
|
|
// 重启某一个operation 保存本地 通知外界
|
|
|
- (void)operationDoningWithOperation:(customDownloadOperation *)operation {
|
|
|
HLog(@"DownloadTaskExeing");
|
|
|
|
|
|
- nasDownloadTaskExeingNotNum ++;
|
|
|
- if (nasDownloadTaskExeingNotNum >= 30) {
|
|
|
- nasDownloadTaskExeingNotNum = 0;
|
|
|
+ NSTimeInterval curTime = [[NSDate date] timeIntervalSince1970];
|
|
|
+ NSTimeInterval timeDiff = curTime - operation.preNotTimeInterval;
|
|
|
+
|
|
|
+ HLog(@"控制刷新时间为1秒:%f",timeDiff);
|
|
|
+
|
|
|
+ if (operation.preNotTimeInterval <= 0
|
|
|
+ || timeDiff > 0.8 ) {
|
|
|
+
|
|
|
+ operation.preNotTimeInterval = curTime;
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:nasDownloadTaskExeing object:nil userInfo:@{@"operation" : operation}];
|
|
|
}
|
|
|
}
|