|
@@ -455,18 +455,19 @@
|
|
|
{
|
|
|
|
|
|
if(dataModel.curUploadStateType == uploadStateDone){
|
|
|
- [_fileModelDataArr removeObject:dataModel];
|
|
|
+ //[_fileModelDataArr removeObject:dataModel];
|
|
|
[self handleDatabaseArrDeleteObjectInUploading:dataModel];
|
|
|
[self handleDatabaseArrAddObjectInDone:dataModel];
|
|
|
}
|
|
|
else if(dataModel.curUploadStateType == uploadStateFail){
|
|
|
- [_fileModelDataArr removeObject:dataModel];
|
|
|
+ //[_fileModelDataArr removeObject:dataModel];
|
|
|
[self handleDatabaseArrDeleteObjectInUploading:dataModel];
|
|
|
[self handleDatabaseArrAddObjectInFail:dataModel];
|
|
|
}
|
|
|
|
|
|
+ dataModel.bg_tableName = nasUpLoadFile_tableName;
|
|
|
[dataModel bg_saveOrUpdateAsync:^(BOOL isSuccess) {
|
|
|
- //HLog(@"%@ 写入 %@", model.filename, isSuccess ? @"成功":@"失败");
|
|
|
+ HLog(@"%@ 写入 %@", dataModel.filename, isSuccess ? @"成功":@"失败");
|
|
|
}];
|
|
|
|
|
|
|
|
@@ -569,117 +570,112 @@
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:uploadFileAllTaskDoneNotification object:nil];
|
|
|
}
|
|
|
|
|
|
-#pragma mark 删除本地数据库记录
|
|
|
-- (void)deleteUploadFileRecordBy:(NSMutableArray *)delArr{
|
|
|
-
|
|
|
-// NSMutableArray *curDelArr = [NSMutableArray arrayWithArray:delArr];
|
|
|
-// for (couldPhoneFileModel *dataModel in curDelArr) {
|
|
|
-//
|
|
|
-// //1.内存数据删除
|
|
|
-// [self handleDatabaseArrByDelete:dataModel];
|
|
|
-//
|
|
|
-// //2.删除数据量
|
|
|
-// NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
|
|
|
-//
|
|
|
-// NSString *curStr = [NSString stringWithFormat:@"%@=%@ ",bg_sqlKey(@"bg_id"),bg_sqlValue(dataModel.bg_id)];
|
|
|
-// [where appendString:curStr];
|
|
|
-//
|
|
|
-// [couldPhoneFileModel bg_deleteAsync:nas_box_download_tableName where:where complete:^(BOOL isSuccess) {
|
|
|
-// if(isSuccess){
|
|
|
-//
|
|
|
-// }
|
|
|
-// }];
|
|
|
-//
|
|
|
-//
|
|
|
-// //3.取消下载
|
|
|
-// NSString *urlString = dataModel.fileUrl;
|
|
|
-// NSString *requestURLEncodedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
-//
|
|
|
-// [[nasDownloadManager shareManager] deleteDownloadWithUrl:requestURLEncodedString];
|
|
|
-// }
|
|
|
-
|
|
|
-}
|
|
|
|
|
|
+#pragma mark 删除内存数据记录
|
|
|
+- (void)handleDatabaseArrByDelete:(uploadFileDataModel*)delModel
|
|
|
+{
|
|
|
+ if(_databaseArr && _databaseArr.count == 3 ){
|
|
|
+
|
|
|
+ NSMutableArray *uploadingArr = nil;
|
|
|
+
|
|
|
+ if(delModel.curUploadStateType == uploadStateUploading
|
|
|
+ ||delModel.curUploadStateType == uploadStateSuspend
|
|
|
+ ||delModel.curUploadStateType == uploadStateWait){
|
|
|
+ uploadingArr = _databaseArr[0];
|
|
|
+ }
|
|
|
+ else if(delModel.curUploadStateType == uploadStateDone)
|
|
|
+ {
|
|
|
+ uploadingArr = _databaseArr[1];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ uploadingArr = _databaseArr[2];
|
|
|
+ }
|
|
|
+
|
|
|
+ [uploadingArr removeObject:delModel];
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
#pragma mark 删除本地数据库记录
|
|
|
- (void)deleteUploadFileRecordBy:(NSMutableArray *)delArr withDelCache:(BOOL)isDelCache complete:(custom_complete_B)complete
|
|
|
{
|
|
|
- //逻辑待优化
|
|
|
-// BOOL isSuc = NO;
|
|
|
-//
|
|
|
-// BOOL isDelUploadingModel = NO;
|
|
|
-//
|
|
|
-// NSMutableArray *curDelArr = [NSMutableArray arrayWithArray:delArr];
|
|
|
-// for (uploadFileDataModel *uploadFileDataMod in curDelArr) {
|
|
|
-//
|
|
|
-// NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
|
|
|
-//
|
|
|
-// NSString *curStr = [NSString stringWithFormat:@"%@=%@ ",bg_sqlKey(@"bg_id"),bg_sqlValue(uploadFileDataMod.bg_id)];
|
|
|
-// [where appendString:curStr];
|
|
|
-// isSuc = [uploadFileDataModel bg_delete:upLoadFile_image_tableName where:where];
|
|
|
-//
|
|
|
-// [self handleDatabaseArrByDelete:uploadFileDataMod];
|
|
|
-//
|
|
|
-// //删除本地图片
|
|
|
-// if(isSuc && isDelCache){
|
|
|
-// //判断是否可以删除本地缓存
|
|
|
-// if(_databaseArr && _databaseArr.count == 3 ){
|
|
|
-// NSMutableArray *uploadingArr = _databaseArr[0];
|
|
|
-// NSMutableArray *uploadDoneArr = _databaseArr[1];
|
|
|
-// NSMutableArray *uploadFailArr = _databaseArr[2];
|
|
|
-//
|
|
|
-//
|
|
|
-// BOOL isNeedDel = YES;
|
|
|
-// for (uploadFileDataModel *baseUploadFileDataMod in uploadingArr) {
|
|
|
-// if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
|
|
|
-// isNeedDel = NO;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(isNeedDel){
|
|
|
-// for (uploadFileDataModel *baseUploadFileDataMod in uploadDoneArr) {
|
|
|
-// if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
|
|
|
-// isNeedDel = NO;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(isNeedDel){
|
|
|
-// for (uploadFileDataModel *baseUploadFileDataMod in uploadFailArr) {
|
|
|
-// if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
|
|
|
-// isNeedDel = NO;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(isNeedDel){
|
|
|
-// if(uploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
|
|
|
-// [cachesFileManager removeItemAtPath:uploadFileDataMod.videoFirstImageName type:uploadFileTypeImage error:nil];
|
|
|
-//
|
|
|
-// [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeVideo error:nil];
|
|
|
-// }
|
|
|
-// else{
|
|
|
-// [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeImage error:nil];
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(isSuc && !isDelCache){//上传报云机已经存在文件了 查询本地是否有任务记录
|
|
|
-// [self handleRetryUploadAndDelRecordFun:uploadFileDataMod];
|
|
|
-// }
|
|
|
-//
|
|
|
-// //是否在删除上传中的任务
|
|
|
+ //
|
|
|
+ BOOL isDelUploadingModel = NO;
|
|
|
+
|
|
|
+ NSMutableArray *curDelArr = [NSMutableArray arrayWithArray:delArr];
|
|
|
+ for (uploadFileDataModel *uploadFileDataMod in curDelArr) {
|
|
|
+
|
|
|
+ //1.删除数据库
|
|
|
+ NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
|
|
|
+ NSString *curStr = [NSString stringWithFormat:@"%@=%@ ",bg_sqlKey(@"bg_id"),bg_sqlValue(uploadFileDataMod.bg_id)];
|
|
|
+ [where appendString:curStr];
|
|
|
+ //isSuc = [uploadFileDataModel bg_delete:nasUpLoadFile_tableName where:where];
|
|
|
+ [uploadFileDataModel bg_deleteAsync:nasUpLoadFile_tableName where:where complete:^(BOOL isSuccess) {
|
|
|
+ if(isSuccess){
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+ // 2.删除内存数据
|
|
|
+ [self handleDatabaseArrByDelete:uploadFileDataMod];
|
|
|
+
|
|
|
+ //3.删除缓存的本地数据
|
|
|
+ if(isDelCache){
|
|
|
+ //判断是否可以删除本地缓存
|
|
|
+ if(_databaseArr && _databaseArr.count == 3 ){
|
|
|
+ NSMutableArray *uploadingArr = _databaseArr[0];
|
|
|
+ NSMutableArray *uploadDoneArr = _databaseArr[1];
|
|
|
+ NSMutableArray *uploadFailArr = _databaseArr[2];
|
|
|
+
|
|
|
+
|
|
|
+ BOOL isNeedDel = YES;
|
|
|
+ for (uploadFileDataModel *baseUploadFileDataMod in uploadingArr) {
|
|
|
+ if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
|
|
|
+ isNeedDel = NO;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isNeedDel){
|
|
|
+ for (uploadFileDataModel *baseUploadFileDataMod in uploadDoneArr) {
|
|
|
+ if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
|
|
|
+ isNeedDel = NO;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isNeedDel){
|
|
|
+ for (uploadFileDataModel *baseUploadFileDataMod in uploadFailArr) {
|
|
|
+ if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
|
|
|
+ isNeedDel = NO;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isNeedDel){
|
|
|
+ if(uploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
|
|
|
+ [cachesFileManager removeItemAtPath:uploadFileDataMod.videoFirstImageName type:uploadFileTypeImage error:nil];
|
|
|
+
|
|
|
+ [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeVideo error:nil];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeImage error:nil];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!isDelCache){//上传报云机已经存在文件了 查询本地是否有任务记录
|
|
|
+ //[self handleRetryUploadAndDelRecordFun:uploadFileDataMod];
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否在删除上传中的任务
|
|
|
// if(_fileModelDataArr && _fileModelDataArr.count >0)
|
|
|
// {
|
|
|
// for (uploadFileDataModel *curUploadFileDataMod in _fileModelDataArr)
|
|
|
// {
|
|
|
// if(curUploadFileDataMod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
|
|
|
// [_fileModelDataArr removeObject:curUploadFileDataMod];
|
|
|
-// //[self handleDatabaseArrDeteleInUploading:curUploadFileDataMod];
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
@@ -688,12 +684,11 @@
|
|
|
// if(!isDelUploadingModel){
|
|
|
// if(_curUploadFileDataModel.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
|
|
|
// isDelUploadingModel = YES;
|
|
|
-//
|
|
|
-// [[webSocketManager shareInstance] suspendUploadFileFun];
|
|
|
+// //[[webSocketManager shareInstance] suspendUploadFileFun];
|
|
|
// }
|
|
|
// }
|
|
|
-// }
|
|
|
-//
|
|
|
+ }
|
|
|
+
|
|
|
// if(isDelUploadingModel){
|
|
|
// _isUploadIngType = NO;
|
|
|
// if(_fileModelDataArr.count >=1){
|
|
@@ -701,17 +696,15 @@
|
|
|
// }
|
|
|
// else{
|
|
|
// _curUploadFileDataModel = nil;
|
|
|
-//
|
|
|
// _isSuspendType = NO;
|
|
|
-// //_curUploadFileDataModel.curUploadStateType = uploadStateDone;
|
|
|
// }
|
|
|
// }
|
|
|
-//
|
|
|
-// uploadFileDataModel *RefreshUploadFileDataMod = nil;
|
|
|
-// if(delArr.count >= 1){
|
|
|
-// RefreshUploadFileDataMod = delArr.firstObject;
|
|
|
-// }
|
|
|
-// [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:RefreshUploadFileDataMod];
|
|
|
+
|
|
|
+ uploadFileDataModel *RefreshUploadFileDataMod = nil;
|
|
|
+ if(delArr.count >= 1){
|
|
|
+ RefreshUploadFileDataMod = delArr.firstObject;
|
|
|
+ }
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:RefreshUploadFileDataMod];
|
|
|
|
|
|
complete(YES);
|
|
|
|