|
|
@@ -2036,15 +2036,11 @@ void UncaughtExceptionHandler(NSException *exception) {
|
|
|
DebugLog(@"%d begin",self.current_task);
|
|
|
|
|
|
long long position=[self.download_task [[NSString stringWithFormat:@"item_%d",self.current_task]][@"position"] longLongValue];
|
|
|
- if (position>0) {
|
|
|
- //不需要创建文件;
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
//获取下载文件大小
|
|
|
// self.fileLength = response.expectedContentLength;
|
|
|
NSMutableDictionary* currenttask=[self.download_task [[NSString stringWithFormat:@"item_%d",self.current_task]] mutableCopy];
|
|
|
- currenttask[@"fileLength"] = [NSNumber numberWithLongLong:response.expectedContentLength];
|
|
|
|
|
|
|
|
|
//获取文件名
|
|
|
@@ -2063,6 +2059,15 @@ void UncaughtExceptionHandler(NSException *exception) {
|
|
|
NSString* location=[NSString stringWithFormat:@"%@/%@",ver,response.suggestedFilename];
|
|
|
NSString *filePath = [temp stringByAppendingPathComponent:location];
|
|
|
DebugLog(@"save to: %@",filePath);
|
|
|
+
|
|
|
+ if (position>0) {
|
|
|
+ //不需要创建文件;
|
|
|
+ //创建一个用来写数据的文件句柄
|
|
|
+ self.fileHandle = [NSFileHandle fileHandleForWritingAtPath:filePath];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 第一次获取的才是文件正确大小
|
|
|
+ currenttask[@"fileLength"] = [NSNumber numberWithLongLong:response.expectedContentLength];
|
|
|
//创建一个空的文件到沙盒
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
[fileManager createFileAtPath:filePath contents:nil attributes:nil];
|