完善方法,log 和注释。

This commit is contained in:
QQQ
2024-05-20 14:34:28 +08:00
parent 03fd39eff5
commit cfaa21a860
2 changed files with 24 additions and 9 deletions

View File

@@ -344,9 +344,11 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@kStrongify(self);
switch (status) {
case AFNetworkReachabilityStatusUnknown:
// MARK:
[[UploadFile share] pasuBatchDownload];
break;
case AFNetworkReachabilityStatusNotReachable:
// MARK:
[[UploadFile share] pasuBatchDownload];
break;
case AFNetworkReachabilityStatusReachableViaWWAN:
@@ -358,7 +360,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[Api requestCacheGiftDynamicEffectList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
self.isFirstReachability = YES; // MARK: wifi ==
// Monitor ->
//
NSArray *allResourceList = data.data;
NSSet *allResourceSet = [[NSSet alloc] initWithArray:allResourceList];
NSMutableArray *allResourceURLs = @[].mutableCopy;
@@ -367,12 +369,16 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[allResourceURLs addObject:encodingUrl];
// [self cacheGiftDynamicEffectList:encodingUrl];
}
[[UploadFile share] startBatchDownloadWithURLs:allResourceURLs];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[UploadFile share] startBatchDownloadWithURLs:allResourceURLs];
});
NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 资源总数:%ld", (unsigned long)allResourceURLs.count);
}
}];
} else {
// MARK:
[[UploadFile share] resumeBatchDownload];
}
}
break;
default:

View File

@@ -288,7 +288,14 @@ static UploadFile* manager;
//
- (void)startBatchDownloadWithURLs:(NSArray<NSString *> *)URLs {
if (_manager == nil) {
_manager = [AFHTTPSessionManager manager];
// _manager = [AFHTTPSessionManager manager];
// MARK: 线 APP API 使
//
//
//
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"com.example.app.background"];
_manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration];
_manager.operationQueue.maxConcurrentOperationCount = 10;
_tasks = [NSMutableArray array];
}
@@ -300,6 +307,8 @@ static UploadFile* manager;
NSMutableArray<NSError *> *errors = [NSMutableArray array];
NSMutableArray<NSURL *> *filePaths = [NSMutableArray array];
NSInteger count = 0;
for (NSString *urlStr in URLs) {
NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
@@ -310,9 +319,9 @@ static UploadFile* manager;
//
if ([[NSFileManager defaultManager] fileExistsAtPath:[destinationURL path]]) {
NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 文件已存在,跳过下载: %@", destinationURL);
[filePaths addObject:destinationURL];
continue;
NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 文件已存在,跳过下载: %@", destinationURL);
[filePaths addObject:destinationURL];
continue;
}
NSURLSessionDownloadTask *downloadTask = [self.manager downloadTaskWithRequest:request
@@ -328,9 +337,9 @@ static UploadFile* manager;
[filePaths addObject:filePath];
NSLog("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 下载成功:%@, 时间:%@", filePath, [NSDate date]);
}
if (filePaths.count + errors.count == URLs.count) {
if (filePaths.count + errors.count + count == URLs.count) {
//
NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 资源总数%ld %@", (unsigned long)URLs.count, [NSDate date]);
NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 全部完成%ld %@", (unsigned long)URLs.count, [NSDate date]);
}
}];