|
@@ -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){
|