Преглед изворни кода

1.下载完成的逻辑修改

huangxiaodong пре 1 година
родитељ
комит
a8ca1bc9b9

+ 15 - 11
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+downloadFile.m

@@ -55,6 +55,11 @@
 
 - (void)downloadFileFunServiceResponseFun:(NSData *)fileData  with:(BOOL)isDownloadDone
 {
+    if(isDownloadDone){
+        [self handleDownloadDoneFun];
+        return;
+    }
+    
     NSString *fileName = [self.curDownloadFileModel getFileNameFun];
         
     NSString*pathStr = [cachesFileManager getFilePathWithName:fileName type:DownLoadFileType];
@@ -86,18 +91,13 @@
     
     self.curDownloadFileModel.didDownloadBytes = didDownloadBytes;
    
-//    if(isDownloadDone){
-//        NSInteger i;
-//    }
-//
-//    if(endOfFile == self.curDownloadFileModel.length){
-//        NSInteger i;
-//    }
+
     
-    if(isDownloadDone || endOfFile == self.curDownloadFileModel.length){
-        [self handleDownloadDoneFun];
-    }
-    else{//获取下一片
+//    if(isDownloadDone || endOfFile == self.curDownloadFileModel.length){
+//        [self handleDownloadDoneFun];
+//    }
+//    else
+    {//获取下一片
         
         [[downloadManager shareInstance] DownloadFileChangeingOneFileFun];
         
@@ -121,6 +121,10 @@
         if(image){
             [self loadImageFinished:image];
         }
+        else{
+            [cachesFileManager removeItemAtPath:fileName type:DownLoadFileType error:nil];
+            [[downloadManager shareInstance] DownloadFileFailOneFileFun];
+        }
     }
     else if([self.curDownloadFileModel.fileType isEqualToString:@"video"]){
         [self loadVideoFinished];

+ 10 - 5
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.mm

@@ -312,13 +312,18 @@
     if(curData.length <= 23){
         //data 的位置 装 成功或者失败
         NSData *failTypeData = [curData subdataWithRange:NSMakeRange(20, 1)];
-        //0xcc (204)失败 0xcd (205)文件不存在 0xdd (221)完成
+        //0xcc (204)失败 0xcd (205)文件不存在 0xdd (221)完成  0xbb 187 完成
         int failType;
         [failTypeData getBytes:&failType length:sizeof(failType)];
         
-        if(taskIdStr && [taskIdStr isEqualToString:self.downloadFileTaskUid]
-           && (failType == 204 || failType == 205)){
-            [[downloadManager shareInstance] DownloadFileFailOneFileFun];
+        if(taskIdStr && [taskIdStr isEqualToString:self.downloadFileTaskUid]){
+            
+            if(failType == 204 || failType == 205){
+                [[downloadManager shareInstance] DownloadFileFailOneFileFun];
+            }
+            else if(failType == 221 || failType == 187){
+                [self downloadFileFunServiceResponseFun:[NSData new] with:YES];
+            }
         }
         
         return;
@@ -332,7 +337,7 @@
     NSData *fileData = [curData subdataWithRange:NSMakeRange(20, datalen-8)];
 
     if([taskIdStr isEqualToString:self.downloadFileTaskUid]){
-        [self downloadFileFunServiceResponseFun:fileData with:isDownloadDone];
+        [self downloadFileFunServiceResponseFun:fileData with:NO];
     }
     
 }