Procházet zdrojové kódy

1.nas 下载文件失败逻辑处理

huangxiaodong před 1 rokem
rodič
revize
c722974e42

+ 5 - 0
创维盒子/Pods/YCDownloadSession/YCDownloadSession/Core/YCDownloader.m

@@ -442,7 +442,12 @@ static NSString * const kIsAllowCellar = @"kIsAllowCellar";
 
 - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {
     NSInteger statusCode = [self statusCodeWithDownloadTask:downloadTask];
+    
     if (!(statusCode == 200 || statusCode == 206)) {
+        //hxd add 20240605
+        NSError *error = [NSError errorWithDomain:@"http status code error" code:statusCode userInfo:nil];
+        YCDownloadTask *task = [self taskWithSessionTask:downloadTask];
+        [self completionDownloadTask:task localPath:nil error:error];
         return;
     }
     YCDownloadTask *task = [self taskWithSessionTask:downloadTask];

+ 4 - 1
创维盒子/Pods/YCDownloadSession/YCDownloadSession/YCDownloadManager.m

@@ -246,7 +246,7 @@ static id _instance;
     YCDownloadTask *task = [[YCDownloader downloader] downloadWithRequest:request progress:item.progressHandler completion:item.completionHandler priority:priority];
     item.taskId = task.taskId;
     
-    //hxd 20240605 item 变多
+    //hxd 20240605 item 修复变多
     if(oldItem){
         [YCDownloadDB removeItemWithTaskId:oldItem.taskId];
     }
@@ -297,6 +297,9 @@ static id _instance;
 - (void)resumeDownloadWithItem:(YCDownloadItem *)item{
     if ([self downloadFinishedWithItem:item]) {
         NSLog(@"[resumeDownloadWithItem] detect item finished : %@", item);
+        //hxd add 20240605
+        [[NSNotificationCenter defaultCenter] postNotificationName:kDownloadTaskFinishedNoti object:item];
+        
         [self startNextDownload];
         return;
     }

+ 12 - 9
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxDownloadFileManager.m

@@ -46,7 +46,7 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
     config.uid = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
     HLog(@"%@",config.uid);
     config.maxTaskCount = 1;
-    config.taskCachekMode = YCDownloadTaskCacheModeDefault;//YCDownloadTaskCacheModeKeep;
+    config.taskCachekMode = YCDownloadTaskCacheModeKeep;//YCDownloadTaskCacheModeDefault;
     config.launchAutoResumeDownload = NO;
     [YCDownloadManager mgrWithConfig:config];
     [YCDownloadManager allowsCellularAccess:YES];
@@ -96,13 +96,13 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
             }
         }
         
-        if(downloadingFail && downloadingFail.count > 0){
-            for (ShareFileDataModel*dataModel in downloadingFail) {
-                if([urlString isEqualToString:dataModel.fileUrl]){
-                    isNeedStopType = NO;
-                }
-            }
-        }
+//        if(downloadingFail && downloadingFail.count > 0){
+//            for (ShareFileDataModel*dataModel in downloadingFail) {
+//                if([urlString isEqualToString:dataModel.fileUrl]){
+//                    isNeedStopType = NO;
+//                }
+//            }
+//        }
         
         if(isNeedStopType){
             HLog(@"停止多的下载任务:%@",item.downloadURL);
@@ -515,7 +515,10 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
         {
             NSArray *allDownItemArr = [YCDownloadManager itemsWithDownloadUrl:requestURLEncodedString];
             
-            if(allDownItemArr.count == 1){
+            if(allDownItemArr.count == 0){
+                [self beginDownloadFilesByUrls:arr];
+            }
+            else if(allDownItemArr.count == 1){
                 YCDownloadItem *item = allDownItemArr.firstObject;
                 [YCDownloadManager resumeDownloadWithItem:item];
             }