|
|
@@ -262,7 +262,10 @@ static downloadManager * cur_downloadManager = nil;
|
|
|
// NSString *fileName = [_curDownloadFileModel getFileNameFun];
|
|
|
// [cachesFileManager removeItemAtPath:fileName type:DownLoadFileType error:nil];
|
|
|
|
|
|
-
|
|
|
+ //1.先做数据保存
|
|
|
+ NSDictionary *dataDict = [_curDownloadFileModel downLoadInfoWithFinished:YES];
|
|
|
+ [self saveFileInfoWithDict:dataDict with:_curDownloadFileModel.path];
|
|
|
+
|
|
|
[self DownloadFileChangeingOneFileFun];
|
|
|
|
|
|
if(_isSuspendType){
|
|
|
@@ -601,4 +604,104 @@ static downloadManager * cur_downloadManager = nil;
|
|
|
|
|
|
}];
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark- ws download done plist Path
|
|
|
+- (NSString *)getDownloadDonePlistPath {
|
|
|
+ NSString *fileFolder = [NSString stringWithFormat:@"%@/DownLoadFlie",CachesPatch];;
|
|
|
+ return [fileFolder stringByAppendingPathComponent:@"webSocketDownloadDoneInfo.plist"];;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark- download done plist
|
|
|
+- (NSMutableDictionary *)getDownloadDownList {
|
|
|
+
|
|
|
+ if (!_downloadDoneList) { // 内存没有
|
|
|
+ _downloadDoneList = [[NSDictionary dictionaryWithContentsOfFile:[self getDownloadDonePlistPath]] mutableCopy]; // 本地加载
|
|
|
+ if (!_downloadDoneList) { // 本地没有,分配内存
|
|
|
+ _downloadDoneList = [NSMutableDictionary dictionary];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return _downloadDoneList;
|
|
|
+}
|
|
|
+
|
|
|
+/** 增加配置信息 */
|
|
|
+- (BOOL)saveFileInfoWithDict:(NSDictionary *)dict with:(NSString*)url {
|
|
|
+ HLog(@"saveFileInfoWithDict:%@",url)
|
|
|
+ if(!dict || !url){
|
|
|
+ return NO;
|
|
|
+ }
|
|
|
+
|
|
|
+ BOOL flag = NO;
|
|
|
+ @synchronized (self) {
|
|
|
+ NSString *key = url;
|
|
|
+ NSMutableDictionary *dictM = [self getDownloadDownList];
|
|
|
+ [dictM setObject:dict forKey:key];
|
|
|
+ flag = [dictM writeToFile:[self getDownloadDonePlistPath] atomically:YES];
|
|
|
+ }
|
|
|
+
|
|
|
+ return flag;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/** 删除配置信息 */
|
|
|
+- (BOOL)deleteFileInfoWithUrl:(NSString *)url {
|
|
|
+ if(!url){
|
|
|
+ return NO;
|
|
|
+ }
|
|
|
+
|
|
|
+ BOOL flag = NO;
|
|
|
+ @synchronized (self) {
|
|
|
+ NSMutableDictionary *dictM = [self getDownloadDownList];
|
|
|
+ [dictM removeObjectForKey:url];
|
|
|
+ flag = [dictM writeToFile:[self getDownloadDonePlistPath] atomically:YES];
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark-保存完成后 删除此次信息 download done plist
|
|
|
+- (void)deleteDownloadDonePlistInfoBy:(NSString*)fullPath
|
|
|
+{
|
|
|
+ HLog(@"deleteDownloadDonePlistInfoBy:%@",fullPath)
|
|
|
+ NSMutableDictionary *dictM = [self getDownloadDownList];
|
|
|
+ for (NSString*key in dictM) {
|
|
|
+ NSDictionary*dict = dictM[key];
|
|
|
+
|
|
|
+ if ([[dict allKeys] containsObject:@"fullPath"]) {
|
|
|
+ NSString * infofullPath = dict[@"fullPath"];
|
|
|
+
|
|
|
+ if([fullPath isEqualToString:infofullPath]){
|
|
|
+ [self deleteFileInfoWithUrl:key];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark-查询还有没有没处理的任务
|
|
|
+- (void)checkDownloadDonePlistInfoFun
|
|
|
+{
|
|
|
+ NSMutableDictionary *dictM = [[self getDownloadDownList] mutableCopy];
|
|
|
+ if(dictM.count > 0){
|
|
|
+ for (NSString*key in dictM) {
|
|
|
+ NSDictionary*dict = dictM[key];
|
|
|
+ couldPhoneFileModel *model = [couldPhoneFileModel mj_objectWithKeyValues:dict];
|
|
|
+ NSString *fileName = [model getFileNameFun];
|
|
|
+ NSString*fullPath = [cachesFileManager getFilePathWithName:fileName type:DownLoadFileType];
|
|
|
+
|
|
|
+ //判断文件是否还存在
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
|
|
|
+ //不存在 删除信息
|
|
|
+ HLog(@"deleteFileInfoWithUrl:%@",key)
|
|
|
+ [self deleteFileInfoWithUrl:key];
|
|
|
+ }
|
|
|
+ else{//存在 通知保存流程
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [[webSocketManager shareInstance] saveDownDoneFileToPhoneFunBy:fullPath withKey:model.path];
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
@end
|