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

1.修复开启备份后 未备份完吧相册删除后 进入备份或者文件上传列表需求读取备份的图片闪退

huangxiaodong пре 8 месеци
родитељ
комит
e849867670

+ 1 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileView/backupsFileRecordCell.m

@@ -396,6 +396,7 @@
         //_glayer.frame = frame;
     }
     
+    HLog(@"111: end");
 }
 
 - (void)handlFileTimelabelFunBy:(NSInteger)speed

+ 16 - 11
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileView/uploadFileRecordCell.m

@@ -244,17 +244,22 @@
                     curUploadFileDataModel.asset = asset;
                 }
                 
-                [[PHImageManager defaultManager] requestImageDataForAsset:curUploadFileDataModel.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
-                        // 直接得到最终的 NSData 数据
-                        if (imageData) {
-                            curUploadFileDataModel.imageData = imageData;
-                            self->_fileImageView.image = [UIImage imageWithData:imageData];
-                            [cachesFileManager getFileNameWithContent:imageData fileName:curUploadFileDataModel.videoFirstImageName type:uploadFileTypeImage];
-                        }
-                        else{
-                            self->_fileImageView.image = [UIImage imageNamed:@"uploadFile_image"];
-                        }
-                }];
+                if(!curUploadFileDataModel.asset){
+                    self->_fileImageView.image = [UIImage imageNamed:@"uploadFile_image"];
+                }
+                else{
+                    [[PHImageManager defaultManager] requestImageDataForAsset:curUploadFileDataModel.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
+                            // 直接得到最终的 NSData 数据
+                            if (imageData) {
+                                curUploadFileDataModel.imageData = imageData;
+                                self->_fileImageView.image = [UIImage imageWithData:imageData];
+                                [cachesFileManager getFileNameWithContent:imageData fileName:curUploadFileDataModel.videoFirstImageName type:uploadFileTypeImage];
+                            }
+                            else{
+                                self->_fileImageView.image = [UIImage imageNamed:@"uploadFile_image"];
+                            }
+                    }];
+                }
             }
         }
         else{

+ 25 - 1
创维盒子/双子星云手机/NAS/nasBackupsManager/nasBackupsManager.m

@@ -12,6 +12,10 @@
 /**检测任务10s后 无反馈重新开始 */
 @property (nonatomic, assign) NSInteger  taskRenewTime; //
 @property (nonatomic,strong)photosBackupsTaskModel *lastModel;//最后一次备份的数据
+
+@property (nonatomic, assign) BOOL isGetFileDataFailType;//获取图片失败
+@property (nonatomic, assign) NSUInteger getFileDataFailCount;//获取图片失败数量
+
 @end
 
 @implementation nasBackupsManager
@@ -39,6 +43,7 @@
 
 - (void)handlePhotosBackupsFun
 {
+    _getFileDataFailCount = 0;
     BOOL haveOpenBackups = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_photo_backups_state)];
     if(!haveOpenBackups){
         return;
@@ -279,13 +284,23 @@
     _curPhotosBackupsTaskMod.didUploadBytes = 0;
     _curPhotosBackupsTaskMod.preDidUploadBytes = 0;
     _curPhotosBackupsTaskMod.totalBytes = 0;
+    HLog(@"curLocalIdentifier:%@---%ld",curLocalIdentifier,_curPhotosBackupsTaskMod.failCount)
+    
+    //单次备份文件图片失败过多
+    if(_getFileDataFailCount >500){
+        _curPhotosBackupsTaskMod.failTaskLocalIdentifier = @"";
+        NSString *tipStr = NSLocalizedString(@"backups_get_file_error_too_many",nil);
+        [self changeBackupsFileStateToFailWith:tipStr];
+        return;
+    }
     
     PHFetchResult *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[curLocalIdentifier] options:nil];
     PHAsset *curAsset = fetchResult.firstObject;
     
     NSString *fileName = [curAsset valueForKey:@"filename"];;
    
-    if(!fileName){
+    if(!fileName || !curAsset){
+        _isGetFileDataFailType = YES;
         [self getDataWrongToChangeFailFun];
         return;
     }
@@ -297,9 +312,11 @@
         [[PHImageManager defaultManager] requestImageDataForAsset:curAsset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
                 // 直接得到最终的 NSData 数据
                 if (imageData) {
+                    weakSelf.isGetFileDataFailType = NO;
                     [weakSelf  afterGetImageDataFun:imageData];
                 }
                 else{
+                    weakSelf.isGetFileDataFailType = YES;
                     [weakSelf getDataWrongToChangeFailFun];
                 }
         }];
@@ -326,13 +343,16 @@
                 BOOL isSuc = [cachesFileManager copyVideoItemAtPath:[urlAsset.URL path] fileName:self->_curPhotosBackupsTaskMod.filename error:nil];
         
                 if (isSuc) {
+                    weakSelf.isGetFileDataFailType = NO;
                     [weakSelf  afterGetVideoDataFun];
                 }
                 else{
+                    weakSelf.isGetFileDataFailType = YES;
                     [weakSelf getDataWrongToChangeFailFun];
                 }
             }
             else{
+                weakSelf.isGetFileDataFailType = YES;
                 [weakSelf getDataWrongToChangeFailFun];
             }
         }];
@@ -345,6 +365,10 @@
     [self deleteVideoFun];
     _curPhotosBackupsTaskMod.failCount += 1;
     
+    if(_isGetFileDataFailType){
+        _getFileDataFailCount += 1;
+    }
+    
     [self RefreshDatabaseFun];
     
     if(_curPhotosBackupsTaskMod.curBackupsState == backupsStateSuspend){

+ 1 - 0
创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

@@ -613,3 +613,4 @@
 "pc_login_ok_tip" = "登录成功";
 "pc_login_fail_tip" = "登录失败,请重试";
 "get_webrtcMsg_fail_tip" = "获取云机信息失败";
+"backups_get_file_error_too_many" = "获取本机图片或者视频错误过多";