Explorar el Código

1.尝试修复nas下载保存到文件授权失败 导致流程中断问题

huangxiaodong hace 1 año
padre
commit
4f40bc9409

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

@@ -254,18 +254,22 @@
             //NSData *fileData = [NSData dataWithContentsOfURL:newURL options:NSDataReadingMappedIfSafe error:&error];
             if (error) {
                 // 读取出错
+                if(self.nasFullPath){
+                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                        [self checkSaveNasFileAgainFun];
+                    });
+                }
             } else {
                 NSLog(@"222 fileName : %@", fileName);
                 if(!self.nasFullPath){
-                    // 下载
+                    // websock下载流程
                     [cachesFileManager removeItemAtPath:fileName type:DownLoadFileType error:nil];
                 }
                 else{
-                    
+                    //nas下载流程
                     [[NSFileManager defaultManager] removeItemAtPath:self.nasFullPath error:nil];
                     [[boxDownloadFileManager shareInstance] deleteDownloadDonePlistInfoBy:self.nasFullPath];
-                    self.nasFullPath = nil;
-                    [[boxDownloadFileManager shareInstance] checkDownloadDonePlistInfoFun];
+                    [self checkSaveNasFileAgainFun];
                 }
                 
             }
@@ -273,8 +277,18 @@
         [urls.firstObject stopAccessingSecurityScopedResource];
     } else {
         // 授权失败
+        if(self.nasFullPath){
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                [self checkSaveNasFileAgainFun];
+            });
+        }
     }
 }
 
-
+#pragma mark 再次读取下载完成数据做保存操作
+- (void)checkSaveNasFileAgainFun
+{
+    self.nasFullPath = nil;
+    [[boxDownloadFileManager shareInstance] checkDownloadDonePlistInfoFun];
+}
 @end