|
@@ -7,7 +7,6 @@
|
|
|
|
|
|
#import "nasDownloadFileManager.h"
|
|
|
@interface nasDownloadFileManager ()
|
|
|
-@property (nonatomic, strong)NSLock *lock;
|
|
|
|
|
|
@end
|
|
|
|
|
@@ -33,7 +32,6 @@ static nasDownloadFileManager * cur_nasDownloadFileManager = nil;
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:nasDownloadTaskExeEnd object:nil];
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:nasDownloadTaskExeError object:nil];
|
|
|
|
|
|
- _lock = [[NSLock alloc] init];
|
|
|
[self initDownloadManagerFun];
|
|
|
}
|
|
|
|
|
@@ -154,8 +152,7 @@ static nasDownloadFileManager * cur_nasDownloadFileManager = nil;
|
|
|
|
|
|
//KWeakSelf
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
|
|
|
-// NSLock *lock = [NSLock new];
|
|
|
-// [lock lock];
|
|
|
+
|
|
|
[couldPhoneFileModel bg_findAsync:nas_box_download_tableName limit:0 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
|
|
|
NSMutableArray *failArr = [NSMutableArray new];
|
|
|
NSMutableArray *doneArr = [NSMutableArray new];
|
|
@@ -174,24 +171,22 @@ static nasDownloadFileManager * cur_nasDownloadFileManager = nil;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- NSLock *lock = [NSLock new];
|
|
|
- [lock lock];
|
|
|
-
|
|
|
- NSMutableArray *newArr = [NSMutableArray new];
|
|
|
- [newArr addObject:otherArr];
|
|
|
- [newArr addObject:doneArr];
|
|
|
- [newArr addObject:failArr];
|
|
|
- self->_databaseArr = newArr;
|
|
|
|
|
|
- [lock unlock];
|
|
|
-
|
|
|
- if(isReGet){
|
|
|
- [self checkDownloadTaskFun];
|
|
|
+ @synchronized (self) {
|
|
|
+
|
|
|
+ NSMutableArray *newArr = [NSMutableArray new];
|
|
|
+ [newArr addObject:otherArr];
|
|
|
+ [newArr addObject:doneArr];
|
|
|
+ [newArr addObject:failArr];
|
|
|
+ self->_databaseArr = newArr;
|
|
|
+
|
|
|
+ if(isReGet){
|
|
|
+ [self checkDownloadTaskFun];
|
|
|
+ }
|
|
|
+
|
|
|
+ complete(self->_databaseArr);
|
|
|
}
|
|
|
-
|
|
|
- complete(self->_databaseArr);
|
|
|
}];
|
|
|
- // [lock unlock];
|
|
|
});
|
|
|
|
|
|
}
|
|
@@ -688,15 +683,13 @@ static nasDownloadFileManager * cur_nasDownloadFileManager = nil;
|
|
|
}
|
|
|
|
|
|
BOOL flag = NO;
|
|
|
- [_lock lock];
|
|
|
+ @synchronized (self) {
|
|
|
NSString *key = url;
|
|
|
NSMutableDictionary *dictM = [self getDownloadDownList];
|
|
|
[dictM setObject:dict forKey:key];
|
|
|
flag = [dictM writeToFile:[self getDownloadDonePlistPath] atomically:YES];
|
|
|
- [_lock unlock];
|
|
|
-
|
|
|
- return flag;
|
|
|
-
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/** 删除配置信息 */
|
|
@@ -719,8 +712,10 @@ static nasDownloadFileManager * cur_nasDownloadFileManager = nil;
|
|
|
{
|
|
|
HLog(@"deleteDownloadDonePlistInfoBy:%@",fullPath)
|
|
|
NSMutableDictionary *dictM = [self getDownloadDownList];
|
|
|
- for (NSString*key in dictM) {
|
|
|
- NSDictionary*dict = dictM[key];
|
|
|
+
|
|
|
+ NSDictionary * forDict = [NSDictionary dictionaryWithDictionary:dictM];
|
|
|
+ for (NSString*key in forDict) {
|
|
|
+ NSDictionary*dict = forDict[key];
|
|
|
|
|
|
if ([[dict allKeys] containsObject:@"fullPath"]) {
|
|
|
NSString * infofullPath = dict[@"fullPath"];
|