|
@@ -58,16 +58,12 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
|
|
|
|
|
|
//图片 和视频 还原
|
|
|
if(curModel.curUploadFileType == uploadFileTypeImage){
|
|
|
-// NSString*pathStr = [cachesFileManager getFilePathWithName:curModel.filename type:uploadFileTypeImage];
|
|
|
-// curModel.imageData = [NSData dataWithContentsOfFile:pathStr];
|
|
|
+
|
|
|
}
|
|
|
else if(curModel.curUploadFileType == uploadFileTypeVideo){
|
|
|
-// NSString*pathStr = [cachesFileManager getFilePathWithName:curModel.videoFirstImageName type:uploadFileTypeImage];
|
|
|
-// curModel.imageData = [NSData dataWithContentsOfFile:pathStr];
|
|
|
-
|
|
|
+
|
|
|
if(curModel.curUploadStateType != uploadStateDone){
|
|
|
- //NSString*videoPathStr = [cachesFileManager getFilePathWithName:curModel.filename type:uploadFileTypeVideo];
|
|
|
- //curModel.videoData = [NSData dataWithContentsOfFile:videoPathStr];
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -114,8 +110,9 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
|
|
|
|
|
|
self.curUploadModelNumbers = indexPathsForSelectedItems.count;
|
|
|
|
|
|
- NSLock *lock = [NSLock new];
|
|
|
+ NSMutableArray *newUploadTaskArr = [NSMutableArray new];
|
|
|
|
|
|
+ NSLock *lock = [NSLock new];
|
|
|
|
|
|
for (TZAssetModel * model in indexPathsForSelectedItems) {
|
|
|
uploadFileDataModel * curModel = [uploadFileDataModel new];
|
|
@@ -188,25 +185,27 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //[_fileModelDataArr addObject:curModel];
|
|
|
-
|
|
|
//保存到数据库
|
|
|
curModel.bg_tableName = upLoadFile_image_tableName;
|
|
|
-
|
|
|
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
|
|
|
- [curModel bg_saveOrUpdateAsync:^(BOOL isSuccess) {
|
|
|
- //HLog(@"%@ 写入 %@", curModel.filename, isSuccess ? @"成功":@"失败");
|
|
|
- }];
|
|
|
- });
|
|
|
+ [newUploadTaskArr addObject:curModel];
|
|
|
|
|
|
}
|
|
|
|
|
|
KWeakSelf
|
|
|
- [self getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
|
|
|
- complete(Arr);
|
|
|
- [weakSelf handleUploadFileModelBg_idFun:Arr];
|
|
|
- }];
|
|
|
+ if(newUploadTaskArr.count == 0){
|
|
|
+ [self getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
|
|
|
+ complete(Arr);
|
|
|
+ [weakSelf handleUploadFileModelBg_idFun:Arr];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ [uploadFileDataModel bg_saveOrUpdateArrayAsync:newUploadTaskArr complete:^(BOOL isSuccess) {
|
|
|
+ [weakSelf getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
|
|
|
+ complete(Arr);
|
|
|
+ [weakSelf handleUploadFileModelBg_idFun:Arr];
|
|
|
+ }];
|
|
|
+ }];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#pragma mark 处理当前的model 加上bg_id
|
|
@@ -472,7 +471,7 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
|
|
|
{
|
|
|
if(_databaseArr && _databaseArr.count == 3 ){
|
|
|
NSMutableArray *uploadDoneArr = _databaseArr[1];
|
|
|
- [uploadDoneArr addObject:uploadmodel];
|
|
|
+ [uploadDoneArr insertObject:uploadmodel atIndex:0];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -480,7 +479,7 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
|
|
|
{
|
|
|
if(_databaseArr && _databaseArr.count == 3 ){
|
|
|
NSMutableArray *uploadFailArr = _databaseArr[2];
|
|
|
- [uploadFailArr addObject:uploadmodel];
|
|
|
+ [uploadFailArr insertObject:uploadmodel atIndex:0];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -684,15 +683,8 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
|
|
|
[self beginUploadFileFun];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //继续下一个
|
|
|
-// if(_fileModelDataArr){
|
|
|
-// [_fileModelDataArr removeObject:_curUploadFileDataModel];
|
|
|
-// _isUploadIngType = NO;
|
|
|
-// if(_fileModelDataArr.count >=1){
|
|
|
-// [self beginUploadFileFun];
|
|
|
-// }
|
|
|
-// }
|
|
|
+
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:nil];
|
|
|
|
|
|
complete(isSuc);
|
|
|
|